2013-11-23 31 views
0

我有以下幾個主要文件:如何在sencha touch中獲取嵌套列表?

app.js:

Ext.Loader.setConfig({ 
}); 
Ext.application({ 
    views: [ 
     'Login', 
     'Inner', 
     'Group', 
     'Innerdata', 
     'Grptoolbar' 
    ], 
    stores:[ 
     'MyStore' 
    ], 
    models:[ 
     'MyModel' 
    ], 
    name: 'chat', 

    launch: function() { 
     Ext.create('chat.view.Login', {fullscreen: true}); 
    } 
}); 

Group.js:是列表視圖文件。

Ext.define('chat.view.Group', { 
    extend: 'Ext.Group', 
    alias: "widget.Group", 
    xtype:'Group', 
    requires:['Ext.dataview.List','Ext.data.Store'], 

    config:{ 
    title:'My List', 
    layout:'fit', 
    items: [ 
     { 
      xtype:'list', 
      store:'MyStore', 
      itemTpl:'<b>{name}<b>' 
     }, 
    ] 
    }, 
}); 

MyModel.js:

Ext.define('chat.model.MyModel',{ 
    extend:'Ext.data.Model', 
    config:{ 
     fields: [ 
     {name: 'text', type: 'string'}, 
     {name: 'card'} 
    ] 
    } 
}); 

MyStore.js

Ext.define('chat.store.MyStore',{ 
    extend:'Ext.data.TreeStore', 
    config:{ 
     model:'chat.model.MyModel', 
     root: { 
     items: [{ 
      text: 'About', 
      card: {xtype: 'Grptoolbar'}, 
      leaf: true 
     } 
     ], 
     }, 
     autoLoad:true, 
     proxy: { 
     type: 'ajax', 
     reader: { 
      type: 'tree', 
      root: 'items' 
     } 
    } 
    } 
}); 

我想創建嵌套List.so我創建店,模型和視圖文件。
目前我面臨這樣的錯誤:

Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: reader.tree

如果我刪除以下線形成MyStore.js那麼錯誤消失,並且應用程序正在運行,但我還沒有拿到名單。

proxy: { 
     type: 'ajax', 
     reader: { 
      type: 'tree', 
      root: 'items' 
     } 
    } 

那麼我該如何解決呢?所以我得到我的嵌套列表。

回答

0

沒有「樹狀閱讀器」,所以你不能使用配置type: 'tree',允許的選項是:json,xml,data,array。

此外,當您使用嵌套列表時,不需要爲代理定義「樹型閱讀器」。我認爲這就夠了:

Ext.define('chat.store.MyStore',{ 
    extend:'Ext.data.TreeStore', 
    config:{ 
     model:'chat.model.MyModel', 
     root: { 
      items: [{ 
      text: 'About', 
      card: {xtype: 'Grptoolbar'}, 
      leaf: true 
      }], 
     }, 
     autoLoad:true, 
     defaultRootProperty: 'items' 
    } 
    } 
}); 
相關問題