PDA

View Full Version : How to wait until store is loaded



mcadirci
5 Oct 2010, 12:29 AM
Hello,

I have a store for grid which I load with load function, after store is loaded I want to refresh grid view but I don't know how to detect it.

Here is my code:
function handleSearchButton(){
console.log('Leroooy Jenkinnnssss!');
var proxy=new Ext.data.HttpProxy( {url:'do?op=searchUserCmd&searchStringJsp='+encodeURIComponent(Ext.getCmp('userSearchField').getValue())+getAvailableGroupNames()});
var reader=new Ext.data.JsonReader({
},[
{name: 'login', mapping: 'login'},
{name: 'firstName'},
{name: 'name'},
{name: 'lastName'},
{name: 'secretQuestion'} ,
{name: 'secretQuestionAnswer'} ,
{name: 'role'} ,
{name: 'organization'}
]
);
var store=new Ext.data.Store( {
id: 'searchStore',
proxy:proxy,
reader:reader
});
store.load();
Ext.getCmp('searchGrid').store=store;
Ext.getCmp('searchGrid').getView().refresh();// this line fires before store is loaded
}

Any help would be great.

Thanks.

--
Mehmet

Condor
5 Oct 2010, 12:45 AM
You can use the store 'load' event or the load callback function.

Other remarks:
1. You can't change the store of a grid by assigning one! You need to use the reconfigure method for that.
2. Why are you even creating a new store? You can keep using the same store and just load() it with different params (don't append the params to the url - Ext will do that for you - and set the proxy method to 'GET').

mcadirci
5 Oct 2010, 12:51 AM
Thanks alot Condor, using same store worked.

Your answers are like magic.

=)

--
Mehmet