PDA

View Full Version : [Please IGNORE] store onLoad being called multiple times inside grid?



duskandawn
14 Sep 2010, 6:56 PM
new thread : http://www.sencha.com/forum/showthread.php?109878-Gird-store-onload-fired-multiple-times-%28updated%29
Hi ,
Considering the grid :



Ext.ns('Test.grid');

Test.grid.searchGrid = Ext.extend(Ext.grid.GridPanel, {
title: Test',
initComponent: function() {
var config = {
id: 'searchgrid',
title : 'Data',
hidden : true,
frame:true,
store: this.buildStore(),

};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Test.grid.searchGrid.superclass.initComponent.apply(this, arguments);
},

buildStore : function(){
return new Ext.data.Store({
proxy: new Ext.data.HttpProxy(callRequest({
service : "TestRecord"
})),
reader: new Ext.data.JsonReader({
totalProperty: 'count',
root : 'record',
fields: [
{name:'acctId'},
{name: 'prdTyp'},
]
}),

listeners: {
load: function(store,record,options)
{
alert("called from listener");
}
}
});
// the below loadGrid is called from another js file as Ext.getCmp('searchGrid').loadGrid(test)
loadGrid : function(data){
this.store.load({
params:{
start:data,
limit:10
}
});
this.store.on('load', function() {
alert("called from outside");
});

}
}


What i am seeing is, if i call the loadGrid() function multiple times from the other panel js file which hosts this grid,
i see the alert("called from outside"); call being called multiple times. i.e for the first time when i call, i see the alert coming up one time,
the next time when i call the loadGrid without refreshing the page, i see the alert coming up 2 times.

But this doesnt happen with the alert which is present under the store listener, the alert present there is only called once, no matter how many time i load the store.

Can you please help what is going on here.
In the broader extent, i am reaching to the point that, my complex code running after on-load event in the loadGrid, i may have to move it under listener.
But just wanted to know the reasoning behind this phenomena,

Please advise,