Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load localstorage data in list view in sencha touch?

Tags:

sencha-touch

How to load localstorage data in list view in sencha touch?

I have my model:

Ext.define('SenchaWebWorker.model.tweetsModel', {
extend: 'Ext.data.Model',
requires:['Ext.data.proxy.LocalStorage'],
config: {
    fields: [
    { name: 'id', type: 'string' },
    { name: 'text', type: 'string' },
    { name: 'date', type: 'string' },
    { name: 'uname', type: 'string' },
    { name: 'uid', type: 'string' },
    { name: 'uimgurl', type: 'string' }
    ],
    proxy: {
        type: 'localstorage',
        id  : '_tweetStore'
    }
}});

and my store:

Ext.define('SenchaWebWorker.store.tweetStore', {
extend: "Ext.data.Store",
config: {
    storeId: '_tweetStore',
    model: 'SenchaWebWorker.model.tweetsModel',
    autoLoad:true
}});

please give me some example if possibel. Thanks.

like image 776
Nirav Alagiya Avatar asked Oct 02 '22 14:10

Nirav Alagiya


1 Answers

It's very easy to do, just simply reference your store in the config object of your list, i.e:

Ext.define('MyApp.view.MyList', {
extend: 'Ext.dataview.List',
xtype: 'MyList',
config: {
    store : 'MyStore',
    itemTpl : document.getElementById('tpl_my_list').innerHTML
}
});
like image 88
JoshMorony Avatar answered Oct 05 '22 22:10

JoshMorony