Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / XmlStore.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-data-XmlStore'>/**
19 </span> * @author Ed Spencer
20  * @class Ext.data.XmlStore
21  * @extends Ext.data.Store
22  * @private
23  * @ignore
24  * &lt;p&gt;Small helper class to make creating {@link Ext.data.Store}s from XML data easier.
25  * A XmlStore will be automatically configured with a {@link Ext.data.reader.Xml}.&lt;/p&gt;
26  * &lt;p&gt;A store configuration would be something like:&lt;pre&gt;&lt;code&gt;
27 var store = new Ext.data.XmlStore({
28     // store configs
29     autoDestroy: true,
30     storeId: 'myStore',
31     url: 'sheldon.xml', // automatically configures a HttpProxy
32     // reader configs
33     record: 'Item', // records will have an &quot;Item&quot; tag
34     idPath: 'ASIN',
35     totalRecords: '@TotalResults'
36     fields: [
37         // set up the fields mapping into the xml doc
38         // The first needs mapping, the others are very basic
39         {name: 'Author', mapping: 'ItemAttributes &gt; Author'},
40         'Title', 'Manufacturer', 'ProductGroup'
41     ]
42 });
43  * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
44  * &lt;p&gt;This store is configured to consume a returned object of the form:&lt;pre&gt;&lt;code&gt;
45 &amp;#60?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
46 &amp;#60ItemSearchResponse xmlns=&quot;http://webservices.amazon.com/AWSECommerceService/2009-05-15&quot;&gt;
47     &amp;#60Items&gt;
48         &amp;#60Request&gt;
49             &amp;#60IsValid&gt;True&amp;#60/IsValid&gt;
50             &amp;#60ItemSearchRequest&gt;
51                 &amp;#60Author&gt;Sidney Sheldon&amp;#60/Author&gt;
52                 &amp;#60SearchIndex&gt;Books&amp;#60/SearchIndex&gt;
53             &amp;#60/ItemSearchRequest&gt;
54         &amp;#60/Request&gt;
55         &amp;#60TotalResults&gt;203&amp;#60/TotalResults&gt;
56         &amp;#60TotalPages&gt;21&amp;#60/TotalPages&gt;
57         &amp;#60Item&gt;
58             &amp;#60ASIN&gt;0446355453&amp;#60/ASIN&gt;
59             &amp;#60DetailPageURL&gt;
60                 http://www.amazon.com/
61             &amp;#60/DetailPageURL&gt;
62             &amp;#60ItemAttributes&gt;
63                 &amp;#60Author&gt;Sidney Sheldon&amp;#60/Author&gt;
64                 &amp;#60Manufacturer&gt;Warner Books&amp;#60/Manufacturer&gt;
65                 &amp;#60ProductGroup&gt;Book&amp;#60/ProductGroup&gt;
66                 &amp;#60Title&gt;Master of the Game&amp;#60/Title&gt;
67             &amp;#60/ItemAttributes&gt;
68         &amp;#60/Item&gt;
69     &amp;#60/Items&gt;
70 &amp;#60/ItemSearchResponse&gt;
71  * &lt;/code&gt;&lt;/pre&gt;
72  * An object literal of this form could also be used as the {@link #data} config option.&lt;/p&gt;
73  * &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This class accepts all of the configuration options of
74  * &lt;b&gt;{@link Ext.data.reader.Xml XmlReader}&lt;/b&gt;.&lt;/p&gt;
75  * @xtype xmlstore
76  */
77 Ext.define('Ext.data.XmlStore', {
78     extend: 'Ext.data.Store',
79     alternateClassName: 'Ext.data.XmlStore',
80     alias: 'store.xml',
81
82 <span id='Ext-data-XmlStore-cfg-reader'>    /**
83 </span>     * @cfg {Ext.data.DataReader} reader @hide
84      */
85     constructor: function(config){
86         config = config || {};
87         config = config || {};
88
89         Ext.applyIf(config, {
90             proxy: {
91                 type: 'ajax',
92                 reader: 'xml',
93                 writer: 'xml'
94             }
95         });
96
97         this.callParent([config]);
98     }
99 });
100 </pre>
101 </body>
102 </html>