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