关于ext.data部分
2008-11-26 10:36
141 查看
转自:http://www.javaeye.com/post/437044
Ext控件如何取得数据?
首先我需要知道如何取到数据,于是定义
Ext.data.HttpProxy 其中的URL属性或者指向1个本地文件,或者是发送一个网络请求
OK中途传输一切顺利,于是我得到一个数据的集合,我如何从这个集合中把数据取出来,按照
我定义的格式来安排数据,接下来定义
Ext.data.JsonReader(如果取到的数据是JSON格式的字符串),或者其他,假设是JSON字串
API文档里有段定义
var myReader = new Ext.data.JsonReader({
totalProperty: "results", // The property which contains the total dataset size (optional)
root: "rows", // The property which contains an Array of row objects
id: "id" // The property within each row object that provides an ID for the record (optional)
}, Employee);
一切顺利,现在我能够让Ext认识服务器返回的JSON字串,那么我现在需要的是一个格式化后的cache,把
读到的字串一项项的放入其中,这样控件可以从这个cache里读取数据并且显示,注意jsonreader第2项参数
Employee这个API有定义
var Employee = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
上面的代码做了什么?定义了格式化的cache,于是一项项的数据通过jsonreader,按record的格式放入
其中,注意mapping定义了原始数据和格式化后数据的影射关系,好了把上面的数据请求,读取方法和放数据的
cache包装在一起就成了Ext.data.Store定义的东西.
Ext控件如何取得数据?
首先我需要知道如何取到数据,于是定义
Ext.data.HttpProxy 其中的URL属性或者指向1个本地文件,或者是发送一个网络请求
OK中途传输一切顺利,于是我得到一个数据的集合,我如何从这个集合中把数据取出来,按照
我定义的格式来安排数据,接下来定义
Ext.data.JsonReader(如果取到的数据是JSON格式的字符串),或者其他,假设是JSON字串
API文档里有段定义
var myReader = new Ext.data.JsonReader({
totalProperty: "results", // The property which contains the total dataset size (optional)
root: "rows", // The property which contains an Array of row objects
id: "id" // The property within each row object that provides an ID for the record (optional)
}, Employee);
一切顺利,现在我能够让Ext认识服务器返回的JSON字串,那么我现在需要的是一个格式化后的cache,把
读到的字串一项项的放入其中,这样控件可以从这个cache里读取数据并且显示,注意jsonreader第2项参数
Employee这个API有定义
var Employee = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
上面的代码做了什么?定义了格式化的cache,于是一项项的数据通过jsonreader,按record的格式放入
其中,注意mapping定义了原始数据和格式化后数据的影射关系,好了把上面的数据请求,读取方法和放数据的
cache包装在一起就成了Ext.data.Store定义的东西.
相关文章推荐
- 关于extj4的Ext.data.JsonStore的问题
- 关于Ext.data.ArrayStore的用法
- 关于从不同的URL获取JSON数据时Ext.data.Store反映迟缓问题的解决
- 关于 OGG "Loading data from file to Replicat"同步含有lob字段表的部分记录的关键参数
- 关于Ext内存泄漏的部分心得
- Ext.data专题九:关于scope和createDelegate()
- 关于部分datanode不能正常启动的问题
- 如何把Ext.data.store里的数据一次性用JSON传给后台(添加了后台解析部分)
- 关于在EXT中短暂的记录Ext.data.HttpProxy等传递参数乱码的问题
- ExtJS 3.1.0中Ext.data.Store关于baseParams的BUG修正
- 如何把Ext.data.store里的数据一次性用JSON传给后台(添加了后台解析部分)
- 关于Ext.data.ScriptTagProxy的补充
- 关于Ext内存泄漏的部分心得
- 关于Ext基础部分
- 如何把Ext.data.store里的数据一次性用JSON传给后台(添加了后台解析部分)
- 【转】关于Jquery中ajax方法data参数用法的总结
- MySQL被收购后被删除的关于其核心价值的部分
- 关于vs运行后窗口闪退问题部分解决方案
- [Extjs6]浅谈Ext.data.Store的使用.
- 关于iOS 6 部分UIViewController 转屏问题