PDA

View Full Version : Insert a record in a grouping grid store



harman
14 May 2012, 3:03 AM
Hi,

I am using an Extjs 4 grouping grid using a store that loads the data from a remote resource using Json.
On the load event of the store i want to insert a record at the end of the store. I am doing this:-




Ext.define('gridModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'userName', type: 'String'},
{name: 'userId', type: 'String'},
{name: 'userAge', type: 'String'}
]
});


var store = new Ext.data.Store({
// destroy the store if the grid is destroyed
autoDestroy: true,
pageSize: 20,
model: 'gridModel',
groupField: 'userName',
remoteSort:false,
proxy: {
type: 'ajax',
url: 'getUserData.json',
reader: {
type: 'json',
root : 'userData',
totalProperty : 'totalCount'
}
},
listeners:{
load : function( store, records, successful, operation){
if(successful){
var ins_rec = Ext.create('gridModel',{
userName : 'User99',
userId : 'User99',
userAge : '99'
});
store.insert(store.count(),ins_rec);
}
}
}
});


but it gives this error
"me.summaryGroups[index - 1] is undefined"

Can anyone help and point out what i am doing wrong?

Thanks

harman
14 May 2012, 3:12 AM
Followed this

http://www.sencha.com/forum/showthread.php?144701-how-to-insert-a-row-into-group-summary-grid

b (http://www.sencha.com/forum/showthread.php?144701-how-to-insert-a-row-into-group-summary-grid)ut why cant i insert in a grouping Summary grid??