PDA

View Full Version : need GroupSummary to show Group name



JKeane
9 Feb 2011, 8:58 AM
I've got a Grid set up with both GridSummary and GroupSummary. The user is happy with me setting a static summaryRenderer for a label in the GridSummary:


summaryRenderer: function() {return "TOTAL"}

but would like the GroupSummary "total" column to reflect which group it's on (so "TOTAL (Category X)", "TOTAL (Category Y)", and so on). And that's where I'm stuck.

Since summaryRenderer is used by both plugins, I opted to override GroupSummary's renderSummary method. I've broken it out so the group now shows parentheses after the word "TOTAL", which is a start, but any other help would be awesome.

Here comes the code:

Ext.override(Ext.ux.grid.GroupSummary, {
renderSummary: function (o, cs) {
cs = cs || this.view.getColumnData();
var cfg = this.grid.getColumnModel().config,
buf = [],
c, p = {},
cf, last = cs.length - 1;
for (var i = 0, len = cs.length; i < len; i++) {
c = cs[i];
cf = cfg[i];
p.id = c.id;
p.style = c.style;
p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
if (cf.summaryType) {
p.value = c.renderer(o.data[c.name], p, o);
} else if (cf.summaryRenderer) {
p.value = cf.summaryRenderer(o.data[c.name], p, o) + " (" + "GROUP_NAME_GOES_HERE" + ")";
} else {
p.value = '';
}
if (p.value == undefined || p.value === "") p.value = "&#160;";
buf[buf.length] = this.cellTpl.apply(p);
}

return this.rowTpl.apply({
tstyle: 'width:' + this.view.getTotalWidth() + ';',
cells: buf.join('')
});
}
});

elston
18 Mar 2013, 6:29 AM
override


doGroupEnd : function(buf, g, cs, ds, colCount){
var data = this.calculate(g.rs, cs);
Ext.apply(data,{
gvalue:g.gvalue,
})
buf.push('</div>', this.renderSummary({data: data}, cs), '</div>');
},

//..
and summaryRenderer like this


summaryRenderer: function (value, metadata, record, rowIndex, colIndex, store) {
if (record.data && record.data.gvalue){
return '????? ?? ????? ? '+record.data.gvalue+':';
};
return '?????:'
}