[英]How can i get Nested List in 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,我創建了存儲,模型和查看文件。
目前,我遇到此錯誤:
錯誤:[Ext.createByAlias]無法創建無法識別的別名的實例:reader.tree
如果我從MyStore.js
刪除以下行,則錯誤消失並且應用程序正在運行,但我還沒有列表。
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
}
那么我該如何解決呢? 所以我得到了我的嵌套列表。
沒有“樹閱讀器”,因此您不能使用配置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'
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.