如何使用MemoryProxy将数据加载到存储中
我正在使用MemoryProxy加载JSON存储(我需要使用代理,因为我根据场景使用不同的源)。它有点像这样:
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();
但是当我检查这个时,我可以看到代理有10行数据,而不是存储。我不知道为什么。
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.
任何指针?
所以我错过了Arrayreader
我修改了使用extjs替换arrayStore的arrray示例,其中包含以下
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
});
我正在把这个工作副本放在github的某个地方,因为我找不到任何内存代理工作
I was thinking of putting this working copy somewhere in github, as I couldnt find anything with a memory proxy working