PDA

View Full Version : GroupSummary subtracting a specified Row from cols setup with 'sum' calculation..



SlashEMc2k
1 Sep 2011, 3:25 AM
Has anyone done this and is there an easy way?
With the groupSummary plugin I want to subtract data held within a specific row to show the total.
At the moment the total displays the sum of all rows.

This is what I was thinking of doing calculation and store the total values from the row in an object array and then subtract and return the new total. But it seems a bit messy anything cleaner I can do?

:-/


Ext.ux.grid.GroupSummary.Calculations['totalHours'] = function(v, record, field){
// if row contains active within string
if (record.data.PlanPre.indexOf('Active') != -1) {
//store returned row
this.activeTmp[field] += record.data[field];
}

var total = record.data[field] - (this.activeTmp[field] * 2);
return total;
};


Thanks

SlashEMc2k
1 Sep 2011, 5:44 AM
Well that was easy.. should just look at the code more closely next time..




if (record.data.PlanPre.indexOf('Active') != -1) {
x = v - (record.data[field]||0);
} else if (record.data.PlanPre.indexOf('Plan') != -1) {
x = v + (record.data[field]||0);
} else {
x = v;
}

return x;