2013-07-11 39 views
0

我正在製作一個帶有sencha touch 2(含Architet)的web應用程序,並且本地存儲有問題:數據不在視圖中。sencha touch 2 - 本地存儲數據未在視圖中

如果我檢查「行」有着怎樣的存儲它將返回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' 
     } 
    ] 
}}); 

儲存:

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' 
    } 
}}); 

VIEW:

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

}}); 

回答

0

更改視圖代碼

itemTpl: '<div>Data View Item {codice}</div>', 
相關問題