PDA

View Full Version : Summation of column in GridView



asugama
6 Dec 2007, 8:01 AM
Hi there,

I have a big problem with GridView, I have been banging my head to no avail. No solution so far. So any help will be very much appreciated.

I used Gridview to draw the following table:
E.g.:
Col A Col B Col C
x y 10
z w 20
a b 15
So far no problem at all, but I need to be able to calculate the total summation of col C and display it right the end of col C
E.g.:
Col A Col B Col C
x y 10
z w 20
a b 15
Total 45

I tried using gridsummary, but there will be a +label on top of the grid, so I need to find alternative way of doing this.

Thanks in advance for all of your help.

Cheers

dogomatic
7 Dec 2007, 8:53 AM
GroupSummary is for Ext 2.0. You might have more luck in the 2.0 Help forum (http://extjs.com/forum/forumdisplay.php?f=9).

justCharlie
13 Dec 2007, 12:55 PM
you can do somethign like this:



ds.on('load', function(thisDS, records, o){
var totals = new Ext.data.Record({col A: 'TOTAL', Col B: '', Col C: thisDS.sum('Col C')});
thisDS.insert(thisDS.getTotalCount(), totals);
});


however, sorting will be a problem because you want the total row to stay at the bottom and you won't be able to sort and keep the row at the bottom (I know this will be possible but I just moved on by disabling the sort).