I suppose you are using cell editing . In the case where the afterSaveCell callback is really good for updating the calculated column amount based on the current values ββfrom the quantity and price columns. The corresponding code might be something like the following
afterSaveCell: function (rowid, cellname, value) { var quantity, price, $this; if (cellname === 'quantity' || cellname === 'price') { $this = $(this); quantity = parseFloat($this.jqGrid("getCell", rowid, 'quantity')); price = parseFloat($this.jqGrid("getCell", rowid, 'price')); $this.jqGrid("setCell", rowid, 'amount', quantity * price); } }
The demonstration does almost the same thing, but calculates the "total" as the sum of the "amount" and "tax". For the test, you must change the value from the column "amount" or "tax" and make sure that "total" will be recalculated.
source share