View Full Version : Gird store onload fired multiple times (updated)?

15 Sep 2010, 4:27 AM
(not sure why my previous posts didnt get publish at all, trying again)

Considering the same grid :


Test.grid.searchGrid = Ext.extend(Ext.grid.GridPanel, {
title: Test',
initComponent: function() {
var config = {
id: 'searchgrid',
title : 'Data',
hidden : 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: '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.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, 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,

15 Sep 2010, 5:57 AM
You are registering a new load handler every time you call the function.

You want:

callback: function(){
alert('I am only called after this load is complete');

this.store.on('load', function() {
alert("This handler is removed after being called");
}, this.store, {single: true});

15 Sep 2010, 6:13 AM
Thanks Condor,
That makes perfect sense.
Will always keep this in mind from now on.
But how does callback() differs from this.store.onLoad event ?

15 Sep 2010, 8:49 AM
Callback is called after the load event (can be useful sometimes) and it also called for failed loads (which would trigger the exception event).