Extjs NestedList赢得';不渲染
我正在使用PhoneGap包装器在SenchaTouch2中构建一个应用程序。 我用MVC模式编码,下面是Web服务器中应用程序的链接(用于调试):登录:用户:1,密码:1 我有一个嵌套的列表,其中有一个树存储来加载数据,还有一个.json文件来加载数据 模型 贮藏 看法 另一个视图,调用上一个视图Extjs NestedList赢得';不渲染,extjs,cordova,sencha-touch-2,Extjs,Cordova,Sencha Touch 2,我正在使用PhoneGap包装器在SenchaTouch2中构建一个应用程序。 我用MVC模式编码,下面是Web服务器中应用程序的链接(用于调试):登录:用户:1,密码:1 我有一个嵌套的列表,其中有一个树存储来加载数据,还有一个.json文件来加载数据 模型 贮藏 看法 另一个视图,调用上一个视图 Ext.define("APP.view.Leftmenu", { extend: 'Ext.Panel', xtype: 'leftmenu', config: { items: [
Ext.define("APP.view.Leftmenu", {
extend: 'Ext.Panel',
xtype: 'leftmenu',
config: {
items: [
{
xtype: 'menunestedlist'
}
],
listeners: {
painted: function () {
}
},
},
onleafitemtap: function() {}
});
此嵌套列表呈现为空(您可以在上面的链接中看到并调试)
谢谢你抽出时间
*编辑(data/menu.json)
我刚刚遇到了同样的问题,我再次查看了Sencha文档中的。我注意到所有数据和数据集合都有相同的键(项/文本)。我尝试调整我的JSON响应,发现它有效。这是我的密码: 来自PHP的JSON
{
"items":
[{
"text":"Other",
"items":
[{
"text":"Employee IDs",
"leaf":"true"
}]
}]
}
JAVASCRIPT
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: ['text']
}
});
var treeStore = Ext.create('Ext.data.TreeStore', {
model: 'ListItem',
defaultRootProperty: 'items',
proxy: {
type: 'ajax',
url: 'data/get_sections.php',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
编辑
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: ['text']
}
});
var treeStore = Ext.create('Ext.data.TreeStore', {
model: 'ListItem',
defaultRootProperty: 'items',
proxy: {
type: 'ajax',
url: 'data/get_sections.php',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
看起来您的模型定义使用了“condig”而不是“config”。另外,NestedList似乎需要使用“items”作为集合,使用“text”作为描述。我花了很多时间解决这个问题,直到我意识到我忘记在app.js应用程序的stores数组中列出我的新商店(例如nestedmenu)。您好。我在左菜单视图中添加了“布局:适合”。现在将呈现列表树,但不会显示文本。在我的网络服务器中查看它。我只是将键“name”改为“text”,它就可以工作了。看起来,对于集合,键必须是“items”,对于名称或描述,键必须是“text”。请确保在模型定义的字段列表中对其进行了更改。将“名称”的数据键更改为“文本”,并将模型更改为“文本”。在JSON文件的此处()没有任何更改,键仍然被称为“name”。在文件“menuitem.js”中,您使用的是“condig”而不是“config”。
{
"items": [
{
"id": 1,
"name": "Section #1",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 8,
"name": "Product #1",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 9,
"name": "Product #2",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 2,
"name": "Section #2",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 3,
"name": "Section #3",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 10,
"name": "Product #3",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 11,
"name": "Product #4",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 4,
"name": "Section #4",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 12,
"name": "Product #5",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 13,
"name": "Product #6",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 5,
"name": "Section #5",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 14,
"name": "Product #7",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 6,
"name": "Section #6",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 15,
"name": "Product #8",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 16,
"name": "Product #9",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 17,
"name": "Product #10",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
}
]
},
{
"id": 7,
"name": "Section #7",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 18,
"name": "Product #11",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 19,
"name": "Product #12",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 20,
"name": "Product #13",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
}
]
}
{
"items":
[{
"text":"Other",
"items":
[{
"text":"Employee IDs",
"leaf":"true"
}]
}]
}
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: ['text']
}
});
var treeStore = Ext.create('Ext.data.TreeStore', {
model: 'ListItem',
defaultRootProperty: 'items',
proxy: {
type: 'ajax',
url: 'data/get_sections.php',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});