2015-09-05 66 views
-1

我創建了一個localStorage的商店,並儲存在它的演示值以下這個教程:設置localStorage的商店嵌套列表

http://sureshdotariya.blogspot.com/2013/03/understanding-local-storage-proxy-in.html

而這一切工作正常,我認爲在存儲數據在鍍鉻的資源和它的存在,當我加載頁面加載罰款,沒有錯誤,但它顯示的數據,這是我的看法代碼:

Ext.define('MyTest.view.SearchPanel', { 
    extend: 'Ext.Panel', 
    xtype: 'searchpanel', 
    config: { 
     layout: 'fit', 
     items: [ 
     { 
      xtype: 'nestedlist', 
      title: 'Search Results', 
      displayField: 'Name', 
      store: {  
       storeId: 'UserStore', 
       fields: ['Name'] 
      }, 
     }] 
    } 
}); 

缺少什麼我在這裏?我可以使用本地存儲存儲作爲嵌套列表的存儲嗎?如果是,那麼爲什麼它顯示「找不到任何項目」,我已經在app.js中添加了該商店,我試圖在此視圖中要求它,但這不起作用。

您的幫助表示感謝,謝謝。

+0

你在哪裏把數據在店裏?我看到你在這裏定義一個新的商店,但不是你把任何數據放入它。如果你有一家商店裏面有數據,我猜你有兩家商店 - 一家有數據,一家有視線。請檢查Ext.ComponentQuery.query(「nestedlist」)[0] .getStore()是否包含數據。 – Alexander

回答

1

Ext.dataview.NestedList要求Ext.data.TreeStore而不是Ext.data.Store(在您提供的示例網址中)。

還有root,defaultRootProperty配置要求在Ext.data.TreeStoreleaf屬性的項目。

當然你也可以設置爲Ext.data.proxy.LocalStorage在代理Ext.data.TreeStore,嘗試用這些代碼:

Ext.define('ListApp.model.User', { 
    extend: 'Ext.data.Model', 
    config: { 
     fields: [{ 
      name: 'text', 
      type: 'string' 
     }] 
    } 
}); 
Ext.define('App.store.User', { 
    config: { 
     model: 'ListApp.model.User', 
     defaultRootProperty: 'items', 
     root: data 
     proxy: { 
      type: 'localstorage', 
      id: 'UserInfo' 
     } 
    } 
}); 
+0

我最終將嵌套列表更改爲列表,因爲我不一定需要加載嵌套數據,我不知道嵌套列表需要TreeStore,謝謝!我想我必須穿過那座橋才能到達它 –