PDA

View Full Version : how to get data in a json store



edwin.deloso
23 Dec 2010, 3:23 AM
Hi,

Please let me know how can I get the record in a json store.

I have this store upon reload I want to filter the record for some implementation.

AccessStore.reload({
params : {
func: "103",
propertyId : '1',
moduleId : '2',
userId : '2'

}
})

var records = AccessStore.data.items;
r = records[0].getAt(1);

alert(r);

I cannot get the data of the store. Anyone can help?

Foster
23 Dec 2010, 4:10 AM
is your code written just like that, straight in line? Have you tried writing an event handler, like in AccessStore.on('load', function ...

This way you can move your code where you try to access the records to a place inside the event handler

Otherwise you are trying to do records[0].getAt(1) before any data is even in the store

Condor
23 Dec 2010, 4:16 AM
Loading is asynchronous. Calling load() only sends a request to the server and all code after that will execute directly after that.

You have to wait for the server to respond. You can do that by using a load event handler (like @Foster already metioned) or by using the callback option in the reload parameter.

edwin.deloso
27 Dec 2010, 9:09 PM
Thanks foster and condor.

I got it.