By Alvin Alexander. Last updated: June 4, 2016
As a quick note, the following code shows how to create a Sencha Touch (or ExtJS) store class with static data:
/** * create this store for the top-level Twitter menu items, * where i want a simple static list * ex: sureshdotariya.blogspot.com/2013/07/display-panel-data-on-list-item-tap-in.html */ Ext.define('MiniMe.store.TwitterStore', { extend: 'Ext.data.Store', alias: 'store.TwitterStore', requires: [ 'MiniMe.model.TwitterMenuItem' ], config: { storeId: 'TwitterStore', model: 'MiniMe.model.TwitterMenuItem', autoLoad: true, data: [ { type: 'list', dataValue: 'ak peeps', label: 'List :: ak peeps' }, { type: 'list', dataValue: 'peeps', label: 'List :: peeps' }, { type: 'list', dataValue: 'programmers', label: 'List :: programmers' }, { type: 'list', dataValue: 'scala peeps', label: 'List :: scala peeps' }, { type: 'query', dataValue: '#zen', label: 'Query :: #zen' }, { type: 'query', dataValue: 'Chicago Cubs', label: 'Query :: Chicago Cubs' }, { type: 'trend', dataValue: 'Colorado', label: 'Trend :: Colorado' }, { type: 'trend', dataValue: 'US', label: 'Trend :: U.S.' }, { type: 'trend', dataValue: 'Worldwide', label: 'Trend :: Worldwide' } ] } });
I currently use this static data as a menu in a Sencha Touch application I’m developing. The data will eventually be replaced by dynamic data that I retrieve from Twitter, but I just want to get the app up and running today.
On a related note, the TwitterMenuItem
model class looks like this:
Ext.define('MiniMe.model.TwitterMenuItem', { extend: 'Ext.data.Model', alias: 'model.TwitterMenuItem', config: { fields: [ { name: 'type', type: 'string'}, { name: 'dataValue', type: 'string'}, { name: 'label', type: 'string'} ] } });