]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * <p>Small helper class to make creating {@link Ext.data.Store}s from XML data easier.\r | |
3 | * A XmlStore will be automatically configured with a {@link Ext.data.reader.Xml}.</p>\r | |
4 | * <p>A store configuration would be something like:<pre><code>\r | |
5 | var store = new Ext.data.XmlStore({\r | |
6 | // store configs\r | |
7 | storeId: 'myStore',\r | |
8 | url: 'sheldon.xml', // automatically configures a HttpProxy\r | |
9 | // reader configs\r | |
10 | record: 'Item', // records will have an "Item" tag\r | |
11 | idPath: 'ASIN',\r | |
12 | totalRecords: '@TotalResults'\r | |
13 | fields: [\r | |
14 | // set up the fields mapping into the xml doc\r | |
15 | // The first needs mapping, the others are very basic\r | |
16 | {name: 'Author', mapping: 'ItemAttributes > Author'},\r | |
17 | 'Title', 'Manufacturer', 'ProductGroup'\r | |
18 | ]\r | |
19 | });\r | |
20 | * </code></pre></p>\r | |
21 | * <p>This store is configured to consume a returned object of the form:<pre><code>\r | |
22 | <?xml version="1.0" encoding="UTF-8"?>\r | |
23 | <ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2009-05-15">\r | |
24 | <Items>\r | |
25 | <Request>\r | |
26 | <IsValid>True</IsValid>\r | |
27 | <ItemSearchRequest>\r | |
28 | <Author>Sidney Sheldon</Author>\r | |
29 | <SearchIndex>Books</SearchIndex>\r | |
30 | </ItemSearchRequest>\r | |
31 | </Request>\r | |
32 | <TotalResults>203</TotalResults>\r | |
33 | <TotalPages>21</TotalPages>\r | |
34 | <Item>\r | |
35 | <ASIN>0446355453</ASIN>\r | |
36 | <DetailPageURL>\r | |
37 | http://www.amazon.com/\r | |
38 | </DetailPageURL>\r | |
39 | <ItemAttributes>\r | |
40 | <Author>Sidney Sheldon</Author>\r | |
41 | <Manufacturer>Warner Books</Manufacturer>\r | |
42 | <ProductGroup>Book</ProductGroup>\r | |
43 | <Title>Master of the Game</Title>\r | |
44 | </ItemAttributes>\r | |
45 | </Item>\r | |
46 | </Items>\r | |
47 | </ItemSearchResponse>\r | |
48 | * </code></pre>\r | |
49 | * An object literal of this form could also be used as the {@link #cfg-data} config option.</p>\r | |
50 | * <p><b>Note:</b> This class accepts all of the configuration options of\r | |
51 | * <b>{@link Ext.data.reader.Xml XmlReader}</b>.</p>\r | |
52 | */\r | |
53 | Ext.define('Ext.data.XmlStore', {\r | |
54 | extend: 'Ext.data.Store',\r | |
55 | alias: 'store.xml',\r | |
56 | \r | |
57 | requires: [\r | |
58 | 'Ext.data.proxy.Ajax',\r | |
59 | 'Ext.data.reader.Xml',\r | |
60 | 'Ext.data.writer.Xml'\r | |
61 | ],\r | |
62 | \r | |
63 | constructor: function(config){\r | |
64 | config = Ext.apply({\r | |
65 | proxy: {\r | |
66 | type: 'ajax',\r | |
67 | reader: 'xml',\r | |
68 | writer: 'xml'\r | |
69 | }\r | |
70 | }, config);\r | |
71 | \r | |
72 | this.callParent([config]);\r | |
73 | }\r | |
74 | }); |