Note that there are some explanatory texts on larger screens.

plurals
  1. POSencha touch store - phantom data
    primarykey
    data
    text
    <p>I created a model like</p> <pre><code>Ext.define('MyApp.model.ContainerDetailsModel', { extend: 'Ext.data.Model', alias: 'model.ContainerDetailsModel', config: { fields: [ { name: 'id', allowNull: false, type: 'string' }, { name: 'container_types_id', type: 'string' } ] } }); </code></pre> <p>and a store like this</p> <pre><code>Ext.define('MyApp.store.ContainerDetailsStore', { extend: 'Ext.data.Store', requires: [ 'MyApp.model.ContainerDetailsModel' ], config: { model: 'MyApp.model.ContainerDetailsModel', storeId: 'ContainerDetailsStore', proxy: { type: 'ajax', enablePagingParams: false, url: 'hereIsServiceUrl', reader: { type: 'json' } } } }); </code></pre> <p>Now somewhere in application I tried to get one record like:</p> <pre><code>var detailsStore = Ext.getStore("ContainerDetailsStore"); detailsStore.load(); var detailsRecord = detailsStore.last(); </code></pre> <p>But it gaves me undefined. The json returned by service is ok, it use it in different place as source for list. I already tried to change allowNull to true, but there is no null id in source. I tried set types to 'int' with the same result.</p> <p>So I have tried </p> <pre><code>console.log(detailsStore); </code></pre> <p>Result is like this (just important values):</p> <pre><code>Class { ... loaded: true, data: Class { ... all: Array[1] { length: 1, 0: Class { container_types_id: "1", id: "726", .... } ... } ... }, ... } </code></pre> <p>In the same place </p> <pre><code> console.log(detailsStore.data); </code></pre> <p>returns (as it should):</p> <pre><code> Class { ... all: Array[1] { length: 1, 0: Class { container_types_id: "1", id: "726", .... } ... } </code></pre> <p>but (next line)</p> <pre><code>console.log(detailsStore.data.all); </code></pre> <p>returns</p> <pre><code> [] </code></pre> <p>And it's empty array. When i try any methods from the store it says the store is empty. I wrote console.log() lines one after another - so for sure it doesn't change between them (I try it also in different order or combinations).</p> <p>My browser is Google Chrome 23.0.1271.97 m I use Sencha from <a href="https://extjs.cachefly.net/touch/sencha-touch-2.0.1.1/sencha-touch-all-debug.js" rel="nofollow">https://extjs.cachefly.net/touch/sencha-touch-2.0.1.1/sencha-touch-all-debug.js</a></p> <p>How can I take a record from that store?</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.
    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