Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable setting nested json data on localstorage in sencha touch
    primarykey
    data
    text
    <p>I have problem to setting nested json data on localstorage in sencha.</p> <p>I have Store class:</p> <pre><code> Ext.define('default.store.Top25Store',{ extend: 'Ext.data.Store', config: { autoLoad:true, model: 'default.model.Top25WordFinal', id:'TodaysWord', proxy: { type: 'ajax', url: 'http://alucio.com.np/trunk/dev/sillydic/admin/api/word/my_favourite_words_with_definition/SDSILLYTOKEN/650773253e7f157a93c53d47a866204dedc7c363', reader: { type:'json', rootProperty:'' } } } }); </code></pre> <p>and model class:</p> <pre><code>Ext.define('default.model.Top25WordFinal', { extend: 'Ext.data.Model', requires: ['default.model.Top25WordRaw'], config: { fields: [ {name: 'status', mapping: 'status'}, {name: 'message', mapping: 'message'}, {name: 'name', mapping: 'name'}, {name:'data', mapping: 'data'}, {name: 'definition', mapping: 'definitions.definition'}, {name: 'ratings', mapping: 'definitions.rating'}, {name:'def_id', mapping:'definitions.def_id'}, ], } }); </code></pre> <p>and associated model class:</p> <pre><code>Ext.define('default.model.Top25WordRaw', { extend: 'Ext.data.Model', config: { fields: [ 'name', 'author', 'word_id', 'category', 'definition', 'rating', 'def_id', 'example', 'author', 'is_favourite' ], belongsTo: "default.model.Top25WordFinal" } }); </code></pre> <p>Model that can used in offline:</p> <pre><code>Ext.define('default.model.Top25WordRawOffline', { extend: 'Ext.data.Model', requires: ['default.model.Top25WordOffline'], config: { fields: [ {name: 'status', mapping: 'status'}, {name: 'message', mapping: 'message'}, {name: 'name', mapping: 'name'}, {name:'data', mapping: 'data'}, {name: 'definition', mapping: 'definitions.definition'}, {name: 'ratings', mapping: 'definitions.rating'}, {name:'def_id', mapping:'definitions.def_id'}, ], identifier:'uuid', // IMPORTANT, needed to avoid console warnings! proxy: { type: 'localstorage', id : 'Top25Display' } } }); </code></pre> <p>Where <strong>default.model.Top25WordOffline</strong> is just like <strong>default.model.Top25WordRaw</strong>.</p> <p>View that display accurate format:</p> <pre><code>store: 'Top25Store', itemTpl: new Ext.XTemplate( '&lt;div&gt;', '&lt;tpl for="data"&gt;', '&lt;ul class="parabox"&gt;', '&lt;li&gt;&lt;h2 &gt;&lt;b&gt;{name}&lt;/b&gt; &lt;/h2&gt;', '&lt;tpl for="definitions"&gt;', '&lt;ul class="para-box-wrapper"&gt;', '&lt;li class="{rating}"&gt;&lt;div id = "definition" class="{rating}"&gt;','{definition}', '&lt;span class="authorBox"&gt;&lt;i&gt;Author: {author}&lt;/i&gt;&lt;/span&gt;', '&lt;div id = "favourite" class="{is_favourite}" &gt;&lt;/div&gt;', '&lt;/li&gt;' , '&lt;/div&gt;', '&lt;/ul&gt;&lt;/li&gt;', '&lt;/tpl&gt;', '&lt;/ul&gt;', '&lt;/tpl&gt;', '&lt;/div&gt;' ), </code></pre> <p>I got value on view. but Problem to store in localstorage: in controller,</p> <pre><code>localStore.getProxy().clear(); store.each(function(record) { var rec = { message : record.data.message, definition : record.data.definitions.definition, ratings:"red" // defintion:record.data.definitions.def_id }; localStore.add(rec); localStore.sync(); </code></pre> <p>I have set message on localstorage and static ratings but problem in definition. How to store definitions, please clearfy.</p>
    singulars
    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.
    plurals
    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