By Alvin Alexander. Last updated: June 6, 2016
The following Sencha Touch code shows how to define a Store, where the store references a model, has a proxy, and also uses some configuration parameters to help control the REST/GET URL/URI the store generates:
Ext.define('RadioMobile.store.RadioStreams', { extend: 'Ext.data.Store', requires: 'RadioMobile.model.RadioStream', config: { model: 'RadioMobile.model.RadioStream', proxy: { type: 'ajax', url: '/server/getRadioStreams', method: 'GET', reader: { type: 'json' //root: 'results' }, // get these variables out of the GET url noCache: false, limitParam: undefined, pageParam: undefined, startParam: undefined, } } });
The model this store references is very simple:
Ext.define('RadioMobile.model.RadioStream', { extend: 'Ext.data.Model', config: { fields: [ { name: 'name' } ] } });
The following store kinda-sorta shows that you can define fields directly in the store, instead of needing a model. That can be useful when prototyping or using static data:
Ext.define('RadioMobile.store.Podcasts', { extend: 'Ext.data.Store', // fields: [ // {name: 'filename'} // ], requires: 'RadioMobile.model.Podcast', config: { model: 'RadioMobile.model.Podcast', proxy: { type: 'ajax', url: '/server/getPodcasts', method: 'GET', reader: { type: 'json' }, noCache: true, limitParam: undefined, pageParam: undefined, startParam: undefined }, } });