PDA

View Full Version : How to Update Total Row in Grid from store in extjs4.1



vijayakumar84
24 Jun 2013, 9:13 PM
I have calculated Total Row using SummaryType:sum in Grid View Row at time of Page Loading.If user select combo need to need to display Total Row value from store .My grid Values are coming from different store .Total value are coming from different storeCan anybody tell how to do?
Thanks

slemmon
26 Jun 2013, 2:44 PM
I'm not sure I follow. You're wanting to display a summary row for data other than what is defined in the store associated with the component using the summary feature?

vijayakumar84
28 Jun 2013, 8:31 AM
Hi slemmon
Yes Correct ,I want to update summaryType function.At the time of page loading calculate totAL USING summaryType :sum ;While user selecting combo drop down need to update value from different stor

slemmon
2 Jul 2013, 11:52 AM
Once the field is changed you'll need to refresh the grid's view. Here's an example:



Ext.define('TestResult', {
extend: 'Ext.data.Model',
fields: ['student', {
name: 'mark',
type: 'int'
}]
});


var grid = Ext.create('Ext.grid.Panel', {
width: 400,
height: 200,
title: 'Summary Test',
style: 'padding: 20px',
renderTo: document.body,
features: [{
ftype: 'summary'
}],
store: {
model: 'TestResult',
data: [{
student: 'Student 1',
mark: 84
},{
student: 'Student 2',
mark: 72
},{
student: 'Student 3',
mark: 96
},{
student: 'Student 4',
mark: 68
}]
},
columns: [{
dataIndex: 'student',
text: 'Name',
summaryType: 'count',
summaryRenderer: function(value, summaryData, dataIndex) {
//return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : '');
return summaryTarget.getValue();
}
}, {
dataIndex: 'mark',
text: 'Mark',
summaryType: 'average'
}]
});


var summaryTarget = Ext.widget('textfield', {
renderTo: document.body,
listeners: {
change: function () {
grid.getView().refresh();
},
buffer: 200
}
});