Is there a method allowing me to return my stored data in an ExtJS Grid Panel exactly the way I loaded it using:
var data = [\"value1\", \"value2\"]
Store.lo
I run into my share of trouble trying to access data from store without binding it to a component, and most of it was because store was loaded trough ajax, so it took to use the load event in order to read the data. This worked:
store.load();
store.on('load', function(store, records) {
for (var i = 0; i < records.length; i++) {
console.log(records[i].get('name'));
};
});
proxy: {
type: 'ajax',
actionMethods: {
read: 'POST',
update: 'POST'
},
api: {
read: '/bcm/rest/gcl/fetch',
update: '/bcm/rest/gcl/save'
},
paramsAsJson: true,
reader: {
rootProperty: 'data',
type: 'json'
},
writer: {
allowSingle: false,
writeAllFields: true,
type: 'json'
}
}
Use allowSingle it will convert into array
Try this:
myStore.each( function (model) {
console.log( model.get('name') );
});
You don't need to make any loops and collect/reprocess data. The json object you need is here:
var jsonData = store.proxy.reader.jsonData;
Store.getRange() seems to be exactly what you are searching for. It will return you Ext.data.Record[]
- array of records. If no arguments is passed, all the records are returned.
I always use store.proxy.reader.jsonData
or store.proxy.reader.rawData
For example - this return the items nested into a root node called 'data':
var some_store = Ext.data.StoreManager.lookup('some_store_id');
Ext.each(some_store.proxy.reader.rawData.data, function(obj, i){
console.info(obj);
});
This only works immediately after a store read-operation (while not been manipulated yet).