玩转extjs5之Ext.data.JsonStore与Ext.data.XmlStore(五)
2015-03-19 15:47
483 查看
一、Ext.data.JsonStore
方便从JSON数据创建Ext.data.Store的小巧的帮助类。 JsonStore将自动配置一个Ext.data.reader.Json,例如:
这个store采用一个返回的对象来配置:
二、Ext.data.XmlStore
一个小巧的帮助类,用于更方便的从一个XML的数据来创建Ext.data.Store。 XmlStore将自动配置一个Ext.data.reader.Xml。例如:
这个store采用一个返回的对象来配置:
方便从JSON数据创建Ext.data.Store的小巧的帮助类。 JsonStore将自动配置一个Ext.data.reader.Json,例如:
var store = new Ext.data.JsonStore({ // store configs autoDestroy: true, storeId: 'myStore', proxy: { type: 'ajax', url: 'get-images.php', reader: { type: 'json', root: 'images', idProperty: 'name' } }, //另外,可以配Ext.data.Model的名称(如 Ext.data.Store 中的例子) fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}] });
这个store采用一个返回的对象来配置:
{ images: [ {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)}, {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)} ] }
二、Ext.data.XmlStore
一个小巧的帮助类,用于更方便的从一个XML的数据来创建Ext.data.Store。 XmlStore将自动配置一个Ext.data.reader.Xml。例如:
var store = new Ext.data.XmlStore({ // store configs autoDestroy: true, storeId: 'myStore', url: 'sheldon.xml', // 自动配置一个HttpProxy // reader configs record: 'Item', // 数据将有一个"Item"标签 idPath: 'ASIN', totalRecords: '@TotalResults' fields: [ // 设置field和xml数据的映射 // 第一个需要映射,其他的都很基本 {name: 'Author', mapping: 'ItemAttributes > Author'}, 'Title', 'Manufacturer', 'ProductGroup' ] });
这个store采用一个返回的对象来配置:
<?xml version="1.0" encoding="UTF-8"?> <ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2009-05-15"> <Items> <Request> <IsValid>True</IsValid> <ItemSearchRequest> <Author>Sidney Sheldon</Author> <SearchIndex>Books</SearchIndex> </ItemSearchRequest> </Request> <TotalResults>203</TotalResults> <TotalPages>21</TotalPages> <Item> <ASIN>0446355453</ASIN> <DetailPageURL> http://www.amazon.com/ </DetailPageURL> <ItemAttributes> <Author>Sidney Sheldon</Author> <Manufacturer>Warner Books</Manufacturer> <ProductGroup>Book</ProductGroup> <Title>Master of the Game</Title> </ItemAttributes> </Item> </Items> </ItemSearchResponse>
相关文章推荐
- 玩转extjs5之Ext.data.Model和Ext.data.Store(四)
- 玩转extjs5之Ext.data.Model和Ext.data.Store
- ExtJs中同一个URL构造多个Ext.data.JsonStore --转载
- 浅谈:Ext.data.JsonStore
- ext中ArrayStore,JsonStore,XmlStore的用法
- Ext.data.Store 获取Json数据只有一行,而且是最后一行
- [转载]EXT核心API详解Ext.data(十二)-GroupingStore/JsonStore/SimpleStore javascript
- ext中ArrayStore,JsonStore,XmlStore的用
- 如何把Ext.data.store里的数据一次性用JSON传给后台(添加了后台解析部分)
- ExtJs中同一个URL构造多个Ext.data.JsonStore
- [转载]Ext.data-GroupingStore/JsonStore/SimpleStore
- Ext.data.Store 获取Json数据只有一行,而且是最后一行
- Extjs学习笔记——Ext.data.JsonStore使用说明
- EXT核心API详解(十一)_Ext.data.Store/GroupingStore/JsonStore/SimpleStore
- Ext.data.Store/GroupingStore/JsonStore/SimpleStore
- Ext.data.Store 获取Json数据只有一行,而且是最后一行
- Ext.data-DataReader/ArrayReader/JsonReader/XmlReader
- How to POST data in JSON format in ExtJS 4 Ext.data.store
- Ext.data.Store 获取Json数据只有一行,而且是最后一行
- 如何把Ext.data.store里的数据一次性用JSON传给后台(添加了后台解析部分)