Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / guides / data / examples / simple_store / app.js
1 /**
2  * @example Simple Store
3  *
4  * This example creates a simple store that auto-loads its data from an ajax
5  * proxy. Since we are only dealing with data there is no UI, so a global
6  * variable called "userStore" is created which is an instance of
7  * {@link Ext.data.Store}.
8  *
9  * Feel free to experiment with the "userStore" object on the console command
10  * line. For example - `userStore.getCount()` gets the total number of records
11  * in the store. `userStore.getAt(0)` gets the record at index 0.
12  */
13 Ext.define('User', {
14     extend: 'Ext.data.Model',
15     fields: [
16         {name: 'id', type: 'int'},
17         {name: 'name', type: 'string'}
18     ]
19 });
20
21 var userStore;
22 Ext.require('Ext.data.Store');
23 Ext.onReady(function() {
24     userStore = Ext.create('Ext.data.Store', {
25         model: 'User',
26         autoLoad: true,
27
28         proxy: {
29             type: 'ajax',
30             url: 'data/users.json',
31             reader: {
32                 type: 'json',
33                 root: 'users',
34                 successProperty: 'success'
35             }
36         }
37     });
38 });