Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / data / JsonPStore.js
1 /**
2  * @class Ext.data.JsonPStore
3  * @extends Ext.data.Store
4  * @ignore
5  * @private
6  * <p><b>NOTE:</b> This class is in need of migration to the new API.</p>
7  * <p>Small helper class to make creating {@link Ext.data.Store}s from different domain JSON data easier.
8  * A JsonPStore will be automatically configured with a {@link Ext.data.reader.Json} and a {@link Ext.data.proxy.JsonP JsonPProxy}.</p>
9  * <p>A store configuration would be something like:<pre><code>
10 var store = new Ext.data.JsonPStore({
11     // store configs
12     autoDestroy: true,
13     storeId: 'myStore',
14
15     // proxy configs
16     url: 'get-images.php',
17
18     // reader configs
19     root: 'images',
20     idProperty: 'name',
21     fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
22 });
23  * </code></pre></p>
24  * <p>This store is configured to consume a returned object of the form:<pre><code>
25 stcCallback({
26     images: [
27         {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
28         {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
29     ]
30 })
31  * </code></pre>
32  * <p>Where stcCallback is the callback name passed in the request to the remote domain. See {@link Ext.data.proxy.JsonP JsonPProxy}
33  * for details of how this works.</p>
34  * An object literal of this form could also be used as the {@link #data} config option.</p>
35  * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
36  * <b>{@link Ext.data.reader.Json JsonReader}</b> and <b>{@link Ext.data.proxy.JsonP JsonPProxy}</b>.</p>
37  * @constructor
38  * @param {Object} config
39  * @xtype jsonpstore
40  */
41 Ext.define('Ext.data.JsonPStore', {
42     extend: 'Ext.data.Store',
43     alias : 'store.jsonp',
44
45     /**
46      * @cfg {Ext.data.DataReader} reader @hide
47      */
48     constructor: function(config) {
49         this.callParent(Ext.apply(config, {
50             reader: Ext.create('Ext.data.reader.Json', config),
51             proxy : Ext.create('Ext.data.proxy.JsonP', config)
52         }));
53     }
54 });