PDA

View Full Version : record empty after store.load()



floflo
5 Aug 2009, 11:27 PM
Hi,

i load a JSONStore :


var store = new Ext.data.JsonStore({
url: 'data/entrepot.json',
root: 'entrepot',
fields: ['source', 'name', 'url', 'namespace']
});
store.load();i know it works because i put this store in a grid and it displays my values.
but after the store.load(), when i watch my variable in firebug, the store.data is empty, and no way to navigate threw it...
Why ? and how can i navigate threw my store to operate actions on the values inside ?

thks for help

Condor
5 Aug 2009, 11:43 PM
store.load is asynchronous; it sends a request to the server, but the data won't be available until the response is received from the server.

You should use a load event handler or the callback function, e.g.

store.load({
callback: function(){
alert('# of records: ' + store.getCount());
}
});