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