简体   繁体   中英

Calculate the value of column based on the other columns in JQGrid

I need to calcualte value of a column based on the values of other column . Say I have col A and Col B . As soon as i enter 4 and 5 in these columns respectively. I need a third column which should calculate A * B ie 20 in Column C.

How to achieve this. Is there any live event supported for this ?

Kindly help.

Regards

The solution con depend on how you fill the grid (which datatype you use).

One possible implementation could be the usage of custom formatter . In the way the column C will not contains any input data, but you can use custom formatter to display the calculated value based on the values of two other columns. See the answer for more details.

If you loads the data from the server you can use beforeProcessing callback alternatively. The callback will be called after receiving the data from the server, but before the data will be processed by jqGrid. It allows you to modify the data returned from the server. You can for example include additional data for the column C based on the values from the columns A and B. See the answer for the more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM