sencha touch 2 - 不在视图中的本地存储数据

时间:2013-07-11 02:02:34

标签: sencha-touch-2 local-storage sencha-architect

我正在使用sencha touch 2(使用Architet)创建一个webapp,我遇到了本地存储问题:数据不在视图中。

如果我检查“行”是如何存储它将返回4(正确!),但在视图中不显示这些记录。

你能帮助我吗?

(设置不与产品互动,因此,请忽略它!)

APP.JS:

Ext.application({
models: [
    'Products',
    'Settings'
],
stores: [
    'Settings',
    'Products'
],
views: [
    'Settings',
    'HomePage',
    'ProductsList'
],
controllers: [
    'Main'
],
name: 'YouPazzle',

launch: function() {

    Ext.create('YouPazzle.view.Settings', {fullscreen: true});
}});

控制器:

Ext.define('YouPazzle.controller.Main', {
extend: 'Ext.app.Controller',

config: {
},

launch: function() {
    var Settings = Ext.getStore('Settings');
    if(Settings.data.all.length === 0){
        console.log('Settagglio non eseguito');
    }else{
        console.log('Settagglio eseguito');
        this.goToHomePage();
    }
},

goToHomePage: function() {
    //Ext.Viewport.add(firststep);

    // Reverse the slide direction before using setActiveItem()

    var toPage = Ext.create('YouPazzle.view.HomePage');
    Ext.Viewport.setActiveItem(toPage);

}
});

MODEL:

Ext.define('YouPazzle.model.Products', {
extend: 'Ext.data.Model',

config: {
    fields: [
        {
            name: 'codice'
        },
        {
            name: 'obj'
        }
    ]
}});

STORAGE:

Ext.define('YouPazzle.store.Products', {
extend: 'Ext.data.Store',

requires: [
    'YouPazzle.model.Products'
],

config: {
    autoLoad: true,
    autoSync: true,
    model: 'YouPazzle.model.Products',
    storeId: 'Products',
    proxy: {
        type: 'localstorage'
    }
}});

查看:

Ext.define('YouPazzle.view.ProductsList', {
extend: 'Ext.dataview.DataView',

config: {
    itemId: 'productsList',
    store: 'Products',
    itemTpl: [
        '<div>Data View Item {codice}</div>'
    ],
    items: [
        {
            xtype: 'toolbar',
            docked: 'top',
            title: 'Prodotti',
            items: [

            ]
        }
    ]
}

initialize: function() {

}});

1 个答案:

答案 0 :(得分:0)

更改您的观看代码

   itemTpl: '<div>Data View Item {codice}</div>',