PageRenderTime 8ms CodeModel.GetById 5ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/ext-4.0.7/docs/guides/data/examples/simple_store/app.js

https://bitbucket.org/srogerf/javascript
JavaScript | 38 lines | 24 code | 2 blank | 12 comment | 0 complexity | b4b6f8dc1db7f1f9b586cab6ebbcc636 MD5 | raw file
 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 */
13Ext.define('User', {
14    extend: 'Ext.data.Model',
15    fields: [
16        {name: 'id', type: 'int'},
17        {name: 'name', type: 'string'}
18    ]
19});
20
21var userStore;
22Ext.require('Ext.data.Store');
23Ext.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});