]> git.proxmox.com Git - extjs.git/blame - extjs/packages/core/src/data/JsonStore.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / src / data / JsonStore.js
CommitLineData
6527f429
DM
1/**\r
2 * Small helper class to make creating {@link Ext.data.Store}s from JSON data easier.\r
3 * A JsonStore will be automatically configured with a {@link Ext.data.reader.Json}.\r
4 *\r
5 * A store configuration would be something like:\r
6 *\r
7 * var store = new Ext.data.JsonStore({\r
8 * // store configs\r
9 * storeId: 'myStore',\r
10 *\r
11 * proxy: {\r
12 * type: 'ajax',\r
13 * url: 'get-images.php',\r
14 * reader: {\r
15 * type: 'json',\r
16 * rootProperty: 'images'\r
17 * }\r
18 * },\r
19 *\r
20 * //alternatively, a {@link Ext.data.Model} name can be given (see {@link Ext.data.Store} for an example)\r
21 * fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]\r
22 * });\r
23 *\r
24 * This store is configured to consume a returned object of the form:\r
25 *\r
26 * {\r
27 * images: [\r
28 * {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},\r
29 * {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}\r
30 * ]\r
31 * }\r
32 *\r
33 * An object literal of this form could also be used as the {@link #cfg-data} config option.\r
34 */\r
35Ext.define('Ext.data.JsonStore', {\r
36 extend: 'Ext.data.Store',\r
37 alias: 'store.json',\r
38 requires: [\r
39 'Ext.data.proxy.Ajax',\r
40 'Ext.data.reader.Json',\r
41 'Ext.data.writer.Json'\r
42 ],\r
43\r
44 constructor: function(config) {\r
45 config = Ext.apply({\r
46 proxy: {\r
47 type : 'ajax',\r
48 reader: 'json',\r
49 writer: 'json'\r
50 }\r
51 }, config);\r
52 this.callParent([config]);\r
53 }\r
54});