使用MVC从json文件加载extjs树
在这里,我遇到了一个奇怪的问题,当我从一个json文件加载一棵树时,它进入一个循环,并显示树如下(在一个连续的循环中) 我的json使用MVC从json文件加载extjs树,json,model-view-controller,extjs,tree,store,Json,Model View Controller,Extjs,Tree,Store,在这里,我遇到了一个奇怪的问题,当我从一个json文件加载一棵树时,它进入一个循环,并显示树如下(在一个连续的循环中) 我的json { "success": true, "results": [ { "text": "number 1", "leaf": true }, { "text": "number 2", "leaf": true }, { "text": "number 3", "leaf": true },
{
"success": true,
"results": [
{ "text": "number 1", "leaf": true },
{ "text": "number 2", "leaf": true },
{ "text": "number 3", "leaf": true },
{ "text": "number 4", "expanded": true, "children":[
{ "text": "number 4.1", "leaf": true },
{ "text": "number 4.2", "leaf": true },
{ "text": "number 4.3", "leaf": true }
]},
{ "text": "number 5", "leaf": true }
]
}
我的模型
Ext.define('App.model.TreeModel', {
extend:'Ext.data.Model',
fields: [
{ name: 'text', type: 'string'}
],
proxy:{
type:'ajax',
url: 'data/tree.json',
reader:{
type:'json',
root:'results'
}
}
});
贮藏
看法
我的初始化文件
Ext.application({
name: 'App',
autoCreateViewport: true,
models: ['TreeModel'],
stores: ['MyTreeStore'],
launch: function() {
}
});
不知道它为什么会循环。。有人有主意吗
提前感谢终于找到了解决方案 拆下线路
root:'results'
从模型
并使用
{
text: '.',
children: [{
完整json
{
text: '.',
children: [{
text:'Basic Ext Layouts',
expanded: true,
children:[{
text:'Absolute',
id:'absolute',
leaf:true
},{
text:'Accordion',
id:'accordion',
leaf:true
},{
text:'Anchor',
id:'anchor',
leaf:true
},{
text:'Border',
id:'border',
leaf:true
},{
text:'Card (TabPanel)',
id:'card-tabs',
leaf:true
},{
text:'Card (Wizard)',
id:'card-wizard',
leaf:true
},{
text:'Column',
id:'column',
leaf:true
},{
text:'Fit',
id:'fit',
leaf:true
},{
text:'Table',
id:'table',
leaf:true
},{
text:'vBox',
id:'vbox',
leaf:true
},{
text:'hBox',
id:'hbox',
leaf:true
}]
},{
text:'Custom Layouts',
children:[{
text:'Center',
id:'center',
leaf:true
}]
},{
text:'Combination Examples',
children:[{
text:'Absolute Layout Form',
id:'abs-form',
leaf:true
},{
text:'Tabs with Nested Layouts',
id:'tabs-nested-layouts',
leaf:true
}]
}]
}
root:'results'
{
text: '.',
children: [{
{
text: '.',
children: [{
text:'Basic Ext Layouts',
expanded: true,
children:[{
text:'Absolute',
id:'absolute',
leaf:true
},{
text:'Accordion',
id:'accordion',
leaf:true
},{
text:'Anchor',
id:'anchor',
leaf:true
},{
text:'Border',
id:'border',
leaf:true
},{
text:'Card (TabPanel)',
id:'card-tabs',
leaf:true
},{
text:'Card (Wizard)',
id:'card-wizard',
leaf:true
},{
text:'Column',
id:'column',
leaf:true
},{
text:'Fit',
id:'fit',
leaf:true
},{
text:'Table',
id:'table',
leaf:true
},{
text:'vBox',
id:'vbox',
leaf:true
},{
text:'hBox',
id:'hbox',
leaf:true
}]
},{
text:'Custom Layouts',
children:[{
text:'Center',
id:'center',
leaf:true
}]
},{
text:'Combination Examples',
children:[{
text:'Absolute Layout Form',
id:'abs-form',
leaf:true
},{
text:'Tabs with Nested Layouts',
id:'tabs-nested-layouts',
leaf:true
}]
}]
}