PDA

View Full Version : get store properties without root



taporari
14 May 2010, 1:34 AM
Hi all !
I have a Json file:


{
"success": true,
"error": {},
"data": {item1: val1, item2: val2}
}




myStore = new Ext.data.JsonStore({
url: path_to_my_JsonFile,
root: 'data',
fields: [{
name: 'item1'
}, {
name: 'item2'
}]
});
myStore .load

I want now to get "success" and "error" properties before do anything. Hopefully, someone can tell me the way get them.
thanks

CrazyEnigma
14 May 2010, 7:20 AM
In JsonReader, you can set the successProperty, but I don't know if it will send it to the exception before the load listener.

And you would probably need a Store and set the reader to a JsonReader, instead of a JsonStore.

If this doesn't work, you can always use Ext.Ajax.request before you use loadData on the Store.

By the way, you don't need to post multiple threads.

giri_sri_d
14 May 2010, 5:18 PM
Reading documentation about DataProxy event called "exception" will help you, JsonStore will use this one internally when loading.

taporari
16 May 2010, 10:04 AM
I read docs and changed code but it didn't work. Nothing showed on console. Can you help me configure it correctly


myStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: path_to_my_JsonFile,
listeners: {
exception: function(proxy, type, action, options, res, arg){
console.log('testing');
}
}
}),
root: 'data',
fields: [{
name: 'item1'
}, {
name: 'item2'
}]
});
myStore .load();

By the way, you don't need to post multiple threads. I met a problem during posting, that is reason why I posted multiple threads. I replied a thread but it still hasn't show since 2 days ago
thanks for reading