如何使用MemoryProxy将数据加载到存储中 [英] How to load data into store using a MemoryProxy

查看:175
本文介绍了如何使用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

这篇关于如何使用MemoryProxy将数据加载到存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆