I'm trying to load a JSON store using a MemoryProxy (I need to use a proxy because I use different sources depending on the scenario). It kinda looks like this:
var data = Ext.decode(gridArrayData);
var proxy = new Ext.data.MemoryProxy(data);
var store = new Ext.data.GroupingStore({
proxy: proxy
});
store.load();
However when I inspect this I can see that the proxy has 10 rows of data, but not the store. I'm lost as to why.
Any pointers?
so I was missing the Arrayreader I modified the arrray example that comes with extjs replacing the arrayStore with the following
var nameRecord = Ext.data.Record.create([
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]);
var arrayReader = new Ext.data.ArrayReader({}, nameRecord);
var memoryProxy = new Ext.data.MemoryProxy(myData);
var storeDos = new Ext.data.Store({
reader : arrayReader,
autoLoad: true,
proxy : memoryProxy
});
I was thinking of putting this working copy somewhere in github, as I couldnt find anything with a memory proxy working
This is my simple Store. All in one and ready to load your object-array right away ;-)
Ext.define('MemoryStore', {
extend: 'Ext.data.Store',
requires: [
'Ext.data.proxy.Memory'
],
fields: [{name: 'company'}],
proxy: {
type: 'memory'
}
});
After creating the store, your can load json via loadData
var store = Ext.create("MemoryStore");
store.loadData([
{company:"Skynet"},
{company:"Rocket-Solutions"},
]);
console.debug(store.first().get("name"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With