巢状清单未载入sencha [英] Nested List not loading in sencha
问题描述
我正在尝试将嵌套列表加载到我的Sencha应用程序中.问题是我不熟悉它,我不确定我使用的json文件是否正确.
I am trying to load a Nested list onto my Sencha app. The problem is I am not familiar with it and i am not sure if the json file i am using is correct.
[
{
"text":[
{
"text":"1.1.1",
"leaf":true
}],
"text":[
{
"text":"1.1.1",
"leaf":true
}
]
}
]
这是我的商店代码
//Defining the store for the Nested List
Ext.define('InfoImage.store.nestedListStore', {
extend: 'Ext.data.TreeStore',
requires: 'InfoImage.model.nestedListModel',
id:'nestedListStore',
config:{
//Calling the required model for the Work Item List
model : 'InfoImage.model.nestedListModel',
//Defining the proxy for the Work Item List to pull the data for the List
proxy : {
type : 'ajax',
url : 'app/model/data/list.json',
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true
}
});
我的主要代码是
Ext.define("InfoImage.view.nestedList", {
extend:'Ext.NestedList',
xtype:'nestedList',
id:'nestedList',
config:{
fullscreen:'true',
title:'Nested List',
xtype:'nestedList',
//displayField : 'text',
html:'Nested List on its way!!!',
store:'nestedListStore'
//itemTpl:'{text}'
}
});
显示的输出是[object object].我不知道缺少什么.感谢您的帮助.
The output thats displayed is [object object]. I dont know what is missing. ANy help is appreciated.
推荐答案
您的JSON似乎无法与Ext.NestedList
一起使用,因为text
是您模型的字段,因此不应在JSON文件中将其声明为rootProperty
It seems that your JSON cannot work with Ext.NestedList
because text
is a field of your Model and it should not be declared as rootProperty in your JSON file.
首先,假设您具有以下模型定义:
Firstly, assume that you have this model definition:
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: ['text']
}
});
根据您的数据,您的JSON文件应如下所示:
According to your data, your JSON file should look like this:
items: [
{
text: '1.1',
items: [
{ text: '1.1.1', leaf: true },
{ text: '1.1.2', leaf: true }
]
}
]
您还必须将此配置也添加到您的商店中defaultRootProperty: 'items'
You have to add this config to your Store as well defaultRootProperty: 'items'
这篇关于巢状清单未载入sencha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!