Upgrade to ExtJS 3.2.2 - Released 06/02/2010
[extjs.git] / docs / source / JsonStore.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.2.2
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="cls-Ext.data.JsonStore"></div>/**
16  * @class Ext.data.JsonStore
17  * @extends Ext.data.Store
18  * <p>Small helper class to make creating {@link Ext.data.Store}s from JSON data easier.
19  * A JsonStore will be automatically configured with a {@link Ext.data.JsonReader}.</p>
20  * <p>A store configuration would be something like:<pre><code>
21 var store = new Ext.data.JsonStore({
22     // store configs
23     autoDestroy: true,
24     url: 'get-images.php',
25     storeId: 'myStore',
26     // reader configs
27     root: 'images',
28     idProperty: 'name',
29     fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
30 });
31  * </code></pre></p>
32  * <p>This store is configured to consume a returned object of the form:<pre><code>
33 {
34     images: [
35         {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
36         {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
37     ]
38 }
39  * </code></pre>
40  * An object literal of this form could also be used as the {@link #data} config option.</p>
41  * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
42  * <b>{@link Ext.data.JsonReader JsonReader}</b>.</p>
43  * @constructor
44  * @param {Object} config
45  * @xtype jsonstore
46  */
47 Ext.data.JsonStore = Ext.extend(Ext.data.Store, {
48     <div id="cfg-Ext.data.JsonStore-reader"></div>/**
49      * @cfg {Ext.data.DataReader} reader @hide
50      */
51     constructor: function(config){
52         Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
53             reader: new Ext.data.JsonReader(config)
54         }));
55     }
56 });
57 Ext.reg('jsonstore', Ext.data.JsonStore);</pre>    
58 </body>
59 </html>