PDA

View Full Version : Summary + Nested Grid Columns + Architect



smarmysam
16 May 2013, 4:12 PM
I cant seem to get the above to work guys. Any pointers?

Thanks!

smarmysam
16 May 2013, 4:22 PM
OK i got it, I can paste in the function and add the "summary" type to the leaf node nested columns and it works ok. YAY

smarmysam
16 May 2013, 5:02 PM
This is still a pain. summaryRenderer function gets passed junky data, pretty blank :(

Is there a way to get it from the data source ?

evant
16 May 2013, 5:21 PM
There's not a lot of value in saying that it doesn't work. Post your code!

smarmysam
19 May 2013, 9:18 AM
OK thank you for your interest


This is my grid, tell me if you need any more.


summaryRenderer just fires with junk data.


I log the value, summaryData, dataIndex and none of the info is in there




{
xtype: 'gridpanel',
height: 572,
id: 'grdOutput',
forceFit: true,
store: 'strOutput',
columns: [
{
xtype: 'gridcolumn',
summaryType: 'count',
width: 600,
dataIndex: 'department',
text: 'Department',
columns: [
{
xtype: 'datecolumn',
align: 'center',
dataIndex: 'date',
text: 'Date',
format: 'Y-m-d'
},
{
xtype: 'gridcolumn',
summary: 'sum',
width: 606,
text: 'Quantities',
columns: [
{
xtype: 'numbercolumn',
summaryRenderer: function(value, summaryData, dataIndex) {
console.log(value);
console.log(summaryData);
console.log(dataIndex);
return Ext.String.format('{0}', value);
},
summary: 'sum',
dataIndex: 'quantity_day',
text: 'Day',
format: '0,000'
},
{
xtype: 'numbercolumn',
summaryRenderer: function(value, summaryData, dataIndex) {
return Ext.String.format('{0}', value);
},
summary: 'sum',
dataIndex: 'quantity_night',
text: 'Night',
format: '0,000'
}
}
}
],
features: [
{
ftype: 'grouping',
showSummaryRow: true,
groupHeaderTpl: [
'{columnName}: {name}'
]
},
{
ftype: 'summary'
}
]
}

smarmysam
19 May 2013, 8:45 PM
I ended up just implementing summaryType(records) and that worked ok.


Example to help all you chaps out there :




columns: [
{
xtype: 'numbercolumn',
summaryType: function(records) {
sum = 0;
for( rec in records ) {
var record = records[ rec ];
try{
sum += record.data.quantity_day;
}catch(ex){}
}




return '<strong>'+ Ext.util.Format.number(sum, "0,000") + '</strong>';
},
summary: 'sum',
field: {
xtype: 'numberfield'
},
dataIndex: 'quantity_day',
text: 'Day',
format: '0,000'
}



That works! Hooray, great success.