I am using Sencha touch 2. I have memory loaded from an existing js object:
Ext.define('majestic.store.Dataset', { extend : 'Ext.data.Store', requires : [ 'majestic.model.Dataset', 'majestic.util.config.ConfigurationManager' ], config : { model : 'majestic.model.Dataset', type: 'memory', reader: 'json', autoLoad : true, proxy: { type: 'memory', reader: { type: 'json', rootProperty : 'datasets' } } }, constructor: function(config) { this.callParent(arguments); this.applyData(majestic.util.config.ConfigurationManager.getConfig()); } });
Model:
Ext.define('majestic.model.Dataset', { extend : 'Ext.data.Model', config : { fields : [ 'title' ], associations: [ {type: 'hasMany', model: 'Layer', name: 'layers'} ] } });
And view:
Ext.define('majestic.view.LayerList', { requires: ['majestic.store.Dataset'], extend: 'Ext.dataview.List', config:{ store: 'Dataset', itemTpl: '<div>{id} is {title}</div>', itemSelector: "div" } });
After viewing the data view in Sencha touch, I added autoLoad and itemSelector, but no luck.
Although it works
new majestic.store.Dataset().each(function(i) {console.log(i)});
displays a list of objects with filled data attributes.
UPDATE
I agree with @fbrandel that the first option is how it should work, but after reading the ST source, I realized that the store dataview parameter is interpreted as:
- save object
- json store note as in the first example here
- name of an already created repository that can be resolved using StoreManager.lookup
So, I ended up with:
store:'Dataset' exit store:'Dataset' in view- Adding
storeId : "Dataset" to save, so it can be enabled by StoreManager - Adding
stores: ['Dataset'] , which caused the creation of majestic.store.Dataset and registration with StoreManager
PS This can also be done using the this.setStore(new majestic.store.Dataset()) method in the initialization the GridView method, but I prefer the declarative way, where possible