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