Pacos
1 Sep 2011, 1:00 AM
Hello,
I'm stuck on this issue for two days now, and I'm currently out of ideas to try out.
Here is the issue :
I have a JSONStore :
var playerStore = new Ext.data.JsonStore({
//autoDestroy: true,
storeId: 'playerStore',
proxy: {
type: 'ajax',
url: 'Controller?action=plist',
reader: {
type: 'json',
root: 'players',
idProperty: 'name'
}
},
fields: ['name']
});
playerStore.load({scope : this,
callback: function(records, operation, success) {
console.log(records);
}
});
Controller?action=plist sends this piece of JSON (validated with JSLint) :
{"players":[{"name":"Anna"},{"name":"Bob"},{"name":"Eve"},{"name":"John"}]}
I can also bind this store with a comboBox, which shows correctly the names above.
BUT I cannot access the data with the following JSONStore methods : getAt(), find(), findBy(), last(), etc. In fact, I haven't been able to access the data no matter what I tried.
If I try to do this :
var test = playerStore.getAt(1).get("name");
In Firebug I get the following error :
playerStore.getAt(1) is undefined
If I try to "find()" a record, it always sends back -1.
Do you have any idea/suggestion ? I put a callback on the store.load(), and I can see the records showing up in Firebug, but I wouldn't be able to tell if everything went fine by reading all the details of the trace : my comprehension ability stops here.
Thanks for your much needed help !
I'm stuck on this issue for two days now, and I'm currently out of ideas to try out.
Here is the issue :
I have a JSONStore :
var playerStore = new Ext.data.JsonStore({
//autoDestroy: true,
storeId: 'playerStore',
proxy: {
type: 'ajax',
url: 'Controller?action=plist',
reader: {
type: 'json',
root: 'players',
idProperty: 'name'
}
},
fields: ['name']
});
playerStore.load({scope : this,
callback: function(records, operation, success) {
console.log(records);
}
});
Controller?action=plist sends this piece of JSON (validated with JSLint) :
{"players":[{"name":"Anna"},{"name":"Bob"},{"name":"Eve"},{"name":"John"}]}
I can also bind this store with a comboBox, which shows correctly the names above.
BUT I cannot access the data with the following JSONStore methods : getAt(), find(), findBy(), last(), etc. In fact, I haven't been able to access the data no matter what I tried.
If I try to do this :
var test = playerStore.getAt(1).get("name");
In Firebug I get the following error :
playerStore.getAt(1) is undefined
If I try to "find()" a record, it always sends back -1.
Do you have any idea/suggestion ? I put a callback on the store.load(), and I can see the records showing up in Firebug, but I wouldn't be able to tell if everything went fine by reading all the details of the trace : my comprehension ability stops here.
Thanks for your much needed help !