PDA

View Full Version : jsonreader metadata



hazimdikenli
12 Nov 2010, 4:36 AM
how does jsonreader ask for the metadata, if we do not configure it initially.

is there a form value or query param indicating that the store is asking for the metadata.

plalx
12 Nov 2010, 5:41 AM
At first load, if there's a metaData property in the response, the store will get configured with it. It's also possible the change the metaData at any time. The store will then get reconfigured with the new provided metaData automatically.

hazimdikenli
12 Nov 2010, 6:05 AM
How is my server going to know if it needs to return the metadata, I dont want to return the metadata on each call, coz I am going to be using this with a remote combo.
so maybe pass something in baseParams and reset it on metadatachange event?

plalx
12 Nov 2010, 6:47 AM
Yes, you will have to inform your server to add metaData by passing a flag. It doesn't have to be in baseParams tought, you can just pass it when loading for the first time by using a single beforeload listener.

e.g.


{
listeners: {
'beforeload': function(store, options) {
options.params.metaNeeded = true;
},
single: true
}
}

Animal
12 Nov 2010, 8:12 AM
Or configure your store with



autoLoad: {
params: {
metaNeeded: true
}
}


An object autoLoad is used as options to the load() call.