Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Feb 03, 2008 10:15
open dhtmlx forum
Footer

I have the following scenario:

There are two columns and aroung 50 rows in my grid and the first column stores items and the second column the values of present stock. So the data would look like: pen - 10, paper - 350, .....

Iam trying to display the total stock of each item in my footer. How can i traverse the grid rows and columns and check the item and then add the stock value to the corresponding totoal??
Answer posted by Support on Feb 04, 2008 04:57
You can calculate it as
    var total=0;
    grid.forEachRow(function(id){
       total+=grid.cells(id,1).getValue();
    });

Also, in latest version of grid, you can enable auto-total calculation - just include dhtmlxgrid_filter.js and set next value in footer
    grid.attachFooter("some,#stat_total")