PDA

View Full Version : Group summary for column in the grid



smruti_patra
22 Jan 2008, 9:51 AM
Hi,
I have one grid with four column with numric data, in the fifth column i want to disaply the sum of firtst four column value.

Please give me some idea how to create this using group summary.

I am adding my Grid code below:



var data = Ext.data.Record.create([
{name: 'Goal1'},
{name: 'Goal2'},
{name: 'Goal3'},
{name: 'Goal4'},
{name: 'TotalGoal'}

]);


var dataStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({url : 'List.action'}),
reader: new Ext.data.JsonReader({id: "id", root: "jsonGoalList"}, data),
sortInfo:{field: 'Level', direction: "ASC"}
});

var grid4 = new xg.EditorGridPanel({
id:'button-grid',
store: dataStore,
bbar: pagingbar,
plugins:filters,
cm: new xg.ColumnModel([

{header: "Goal1", width: 120, sortable: true,dataIndex: 'Goal1',align:'right',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},
{header: "Goal2", width: 135, sortable: true,dataIndex: 'Goal2',align:'right',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},
{header: "Goal3",width: 120,sortable: true,dataIndex: 'Goal3',align:'right',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},
{header: "Goal4", width: 120,sortable: true,dataIndex: 'Goal4',align:'right',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},{header: "totalGoal",width: 120,sortable: true, dataIndex: 'TotalGoal',align:'right',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
}

]),

viewConfig: {
forceFit:false
},

width:700,
height:370,
frame:true,
autoScroll:true,
iconCls:'icon-grid'
});


Thanks,
Smruti

castitas
11 Oct 2011, 7:30 AM
Add your fifth column with a column renderer that sums all the values in the row. It shouldn't be too hard, since you can uplevel from your cell to the grid, then iterate through the columns at that specific row. I think. Let me know if it works.
Take a look at the renderer config.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.column.Column