Summing groups ( dhtmlxGrid )

How can i sum each group ?

Basically i want to show an extra row right before the group ends with the totals. ( not in the footer )

Thank you.

There is no build in support for such use-case, but something similar can be done with custom code

      for (var a in mygrid._groups){   // for each group
         var id=mygrid.getUID();
         mygrid.addRow(id,["","",a])   // add total row
         mygrid.setColspan(id,0,8);   // 8 - count of columns in grid
         var total=0;
         mygrid.forEachRow(function(id){   //calculate grid total
            if (mygrid.cells(id,this._gIndex).getValue()==a)
               total+=parseFloat(mygrid.cells(id,3).getValue());   // 3 - index of column for calculations
         mygrid.cells(id,0).setValue(“Total:”+total);   // set total value

Thank you for the solution.

However, this is not what I need.

I need the sum to be at the End of each group, not in the End of the grid.

Thank you…

Did you check the sample code above?
Actually it creates “total” rows for each group in grid, not the single one for whole grid.

Full sample sent by email.

dear support,

do you have a sample where the totals within each group and still remain there even if we change the “group by” for the list?
btw, I am using Prof version of DHTMLX Grid. If you have, can you send it to



There is no such sample ( and possible workaround require pretty complex coding )
The grid doesn’t support such feature as “totals for groups”, the code above just a possible workaround