Note that there are some explanatory texts on larger screens.

plurals
  1. POSencha Touch DataView not showing items from Store
    primarykey
    data
    text
    <p>I'm using Sencha touch 2. I have store that load from existing js object:</p> <pre><code>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()); } }); </code></pre> <p>Model: </p> <pre><code>Ext.define('majestic.model.Dataset', { extend : 'Ext.data.Model', config : { fields : [ 'title' ], associations: [ {type: 'hasMany', model: 'Layer', name: 'layers'} ] } }); </code></pre> <p>And view:</p> <pre><code>Ext.define('majestic.view.LayerList', { requires: ['majestic.store.Dataset'], extend: 'Ext.dataview.List', config:{ store: 'Dataset', itemTpl: '&lt;div&gt;{id} is {title}&lt;/div&gt;', itemSelector: "div" } }); </code></pre> <p>After looking at <a href="https://stackoverflow.com/questions/5535660/data-view-in-sencha-touch">Data view in Sencha touch</a> i've added autoLoad and itemSelector, still no luck.</p> <p>Though running</p> <pre><code>new majestic.store.Dataset().each(function(i) {console.log(i)}); </code></pre> <p>outputs list of objects with filled data attributes.</p> <p><strong>UPDATE</strong></p> <p>I agree with @fbrandel that first option is how it should work, but after reading ST source i've figured out that store parameter of dataview is interpreted as:</p> <ul> <li>store object</li> <li>json store notation like in first example <a href="http://docs.sencha.com/touch/2-0/#!/api/Ext.dataview.DataView" rel="nofollow noreferrer">here</a></li> <li>name of already created store which can be resolved using <a href="http://docs.sencha.com/touch/2-0/#!/api/Ext.data.StoreManager-method-lookup" rel="nofollow noreferrer">StoreManager.lookup</a></li> </ul> <p>So I ended up with: </p> <ol> <li>Leaving <code>store:'Dataset'</code> in View</li> <li>Adding <code>storeId : "Dataset"</code> to store, so it can be resolved by StoreManager</li> <li>Adding <code>stores: ['Dataset']</code> which caused creation of <code>majestic.store.Dataset</code> and registering it in StoreManager</li> </ol> <p><strong>P.S.</strong> It also could be done using <code>this.setStore(new majestic.store.Dataset())</code> in <code>initialization</code> method of GridView, but I prefer declarative way where posible</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload