calculate column sum

i have a grid where in a given column i need to calculate the sum. when the grid loads, column 2 is populated per row so there might be a grid like:

id val
1 2
2 4
3 1

i used the grid.attachEvent(“ondataready” to call a function that loops through the rows of the gird above and returns the sum.

the grid also has two cases where the user can update the grid - textbox/button and inline.
textbox/button - when this is clicked i use the grid.collectvalue(2); hoping to get a sum but i don’t get a summation back. i get the row 1 col 2 value of 2.

the inline edit allows me to change a row/col value but how do i get an accurate summation on the entire grid col2?

i tried grid.attachevent(“oneditcell” and oncellchanged but they kept firing per row which didn’t even recalculate the summation - simply returned the first summation.

any suggestions?

i tried onCellChanged (docs.dhtmlx.com/api__dhtmlxgrid_ … event.html); however, this is being called upon the first grid load multiple times and after i change a cell value it doesn’t get the new value - returns the old value.

Please, try to use the onCellChanged event.

this is being called upon the first grid load multiple times
Please, try to attach the event after the data is loaded:
myGrid.load(url,function(){
myGrid.attachEvent(“onCellChanged”, function(rId,cInd,nValue){
some_func()
});
});

after i change a cell value it doesn’t get the new value - returns the old value.
Unfortunately the problem cannot be reconstructed locally.
Please, provide with the snippet of the using code.