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