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