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