【问题标题】:sencha touch 2 - local storage data not in viewsencha touch 2 - 本地存储数据不在视图中
【发布时间】:2013-07-11 02:02:34
【问题描述】:

我正在使用 sencha touch 2(使用 Architet)制作一个 web 应用程序,但本地存储存在问题:视图中没有数据。

如果我检查“行”如何存储它将返回 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);

}
});

型号:

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

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

存储:

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() {

}});

【问题讨论】:

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


    【解决方案1】:

    更改您的视图代码

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多