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