PDA

View Full Version : Is it possible to get the value of the sum in Summary Grid?



maecy
24 Oct 2013, 1:25 AM
I want to get the sum of all the timeframe from the grid for validation. I am able to display the sum of the values in my grid but I was wonder if I can get the sum value and put it in a variable? Here's my grid code:



Ext.ns('dlti.view.widget');
//User Maintenance grid


Ext.define('dlti.view.widget.PlaylistDetailsGrid' ,{
extend: 'Ext.grid.Panel',
id: 'playlist-details',
alias: 'widget.PlaylistDetailsGrid',
forceFit: true,
stripeRows: true,
selType: 'rowmodel',
autosync: true,
height: 150,
width: 950,
features: [{
ftype: 'summary'
}],



store: new dlti.store.PlaylistDetailsStore(),




columns: [



{
text: 'Filename',
dataIndex: 'filename',
renderer: function renderDescTarget(val, p, record) {
var desc = '';
desc = '<p style="color:#000;font-size:12px;">' + val + '</p>';
return desc;
}
},
{
text: 'Transition',
dataIndex: 'transition',
renderer: function renderDescTarget(val, p, record) {
var desc = '';
desc = '<p style="color:#000;font-size:12px;">' + val + '</p>';
return desc;
}
},
{
text: 'Stay Time',
dataIndex: 'timeframe',
summaryType: 'sum',



}



]
});

Piruthu
24 Oct 2013, 2:10 AM
Just use the store's sum function... try adding the below to your grid


listeners: {
afterrender : function(grid, eOpts){
console.log('Sum >> ', grid.store.sum('timeframe'));
}
}