X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/3789b528d8dd8aad4558e38e22d775bcab1cbd36..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/guides/data/examples/simple_store/app.js diff --git a/docs/guides/data/examples/simple_store/app.js b/docs/guides/data/examples/simple_store/app.js new file mode 100644 index 00000000..62a72442 --- /dev/null +++ b/docs/guides/data/examples/simple_store/app.js @@ -0,0 +1,38 @@ +/** + * @example Simple Store + * + * This example creates a simple store that auto-loads its data from an ajax + * proxy. Since we are only dealing with data there is no UI, so a global + * variable called "userStore" is created which is an instance of + * {@link Ext.data.Store}. + * + * Feel free to experiment with the "userStore" object on the console command + * line. For example - `userStore.getCount()` gets the total number of records + * in the store. `userStore.getAt(0)` gets the record at index 0. + */ +Ext.define('User', { + extend: 'Ext.data.Model', + fields: [ + {name: 'id', type: 'int'}, + {name: 'name', type: 'string'} + ] +}); + +var userStore; +Ext.require('Ext.data.Store'); +Ext.onReady(function() { + userStore = Ext.create('Ext.data.Store', { + model: 'User', + autoLoad: true, + + proxy: { + type: 'ajax', + url: 'data/users.json', + reader: { + type: 'json', + root: 'users', + successProperty: 'success' + } + } + }); +});