PDA

View Full Version : How to access JSON fields within a Ext.data.Store that are NOT in the JSON array?



misterblinky
25 Aug 2011, 10:22 AM
In examples of creating a Store, we always see a json obj more or less like this:


callback({count:2, arrayBase:[{'a': 211, 'b': 'bling'}, 'a': 343, 'b': 'blah'}]})

which works just fine: Ext.data.Store makes records of each element of the array, etc. However, what if you want to add and access more data from within the json object that's not part of the format expected by Ext.data.Store? For example:


callback({count:2, moreData: 'this_data', arrayBase:[{'a': 211, 'b': 'bling'}, 'a': 343, 'b': 'blah'}]})

How can I access that "moreData" variable from within the store?

thanks

httpdotcom
25 Aug 2011, 12:09 PM
http://www.sencha.com/learn/grid-faq/


How to get additional data sent back with store load?
Use reader's jsonData.
myStore.load({
params: {
foo: 'bar',
start: 0,
limit: 10
},
//scope:myStore
callback: function(rec, options, success){
var reader = this.reader;
var jsonData = reader.jsonData;
console.dir(jsonData);
}
});

misterblinky
11 Nov 2011, 11:04 AM
thank you ... worked