Extjs 如何在一个请求中加载树面板中的所有节点(及其子节点)?
我试图创建一个树面板,在创建时在一个请求中加载它的所有项(及其子项)。从我读到的所有内容来看,如果项具有“children”属性,则它们不应在展开时再次尝试加载子项,而我的则是这样Extjs 如何在一个请求中加载树面板中的所有节点(及其子节点)?,extjs,extjs4,extjs4.2,Extjs,Extjs4,Extjs4.2,我试图创建一个树面板,在创建时在一个请求中加载它的所有项(及其子项)。从我读到的所有内容来看,如果项具有“children”属性,则它们不应在展开时再次尝试加载子项,而我的则是这样 Ext.define('ec.view.MarketGroupTree', { extend: 'Ext.tree.Panel', requires:[ 'Ext.tree.*', 'Ext.data.*' ], xtype: 'market-group-tree', store: Ext.cre
Ext.define('ec.view.MarketGroupTree', {
extend: 'Ext.tree.Panel',
requires:[
'Ext.tree.*',
'Ext.data.*'
],
xtype: 'market-group-tree',
store: Ext.create('Ext.data.TreeStore', {
autoLoad: true,
root: {
expanded: true
},
fields: ['marketGroupName', 'children', 'marketGroupID'],
proxy: {
type: 'ajax',
url: 'backend/market.php?a=marketGroupTree',
reader: {
type: 'json',
root: 'records'
}
}
}),
rootVisible: false,
rowLines: true,
sealedColumns: true,
singleExpand: true,
useArrows: true,
headerPosition: 'left',
lines: false,
columns: {
items: [
{
xtype: 'treecolumn',
dataIndex: 'marketGroupName',
flex: 1
},
{
xtype: 'treecolumn',
dataIndex: 'marketGroupID',
flex: 0.3
}
]
}
});
从backend/market.php?A=marketGroupTree接收到的JSON示例位是:
{
"success":true,
"records":[
{
"marketGroupID":"2",
"marketGroupName":"Blueprints",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"204",
"marketGroupName":"Ships",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"205",
"marketGroupName":"Frigates",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"261",
"marketGroupName":"Caldari",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"264",
"marketGroupName":"Minmatar",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
},
{
"marketGroupID":"206",
"marketGroupName":"Cruisers",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"273",
"marketGroupName":"Minmatar",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"274",
"marketGroupName":"Amarr",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
}
]
},
{
"marketGroupID":"209",
"marketGroupName":"Ship Equipment",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"210",
"marketGroupName":"Turrets & Bays",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"286",
"marketGroupName":"Hybrid Turrets",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"289",
"marketGroupName":"Large",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"290",
"marketGroupName":"Medium",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
},
{
"marketGroupID":"287",
"marketGroupName":"Projectile Turrets",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"296",
"marketGroupName":"Small",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"297",
"marketGroupName":"Medium",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
}
]
},
{
"marketGroupID":"214",
"marketGroupName":"Hull & Armor ",
"iconID":"2703",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"335",
"marketGroupName":"Hull Upgrades",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"1536",
"marketGroupName":"Armor Repairers",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
}
]
}
]
},
{
"marketGroupID":"4",
"marketGroupName":"Ships",
"iconID":"1443",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"391",
"marketGroupName":"Shuttles",
"iconID":"1443",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"393",
"marketGroupName":"Amarr",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"394",
"marketGroupName":"Minmatar",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
},
{
"marketGroupID":"1361",
"marketGroupName":"Frigates",
"iconID":"1443",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"5",
"marketGroupName":"Standard Frigates",
"iconID":"1443",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"61",
"marketGroupName":"Caldari",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"64",
"marketGroupName":"Minmatar",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
},
{
"marketGroupID":"1362",
"marketGroupName":"Faction Frigates",
"iconID":"1443",
"hasTypes":"1",
"leaf":false,
"children":[
{
"marketGroupID":"1365",
"marketGroupName":"Pirate Faction",
"iconID":"0",
"hasTypes":"1",
"leaf":true
},
{
"marketGroupID":"1366",
"marketGroupName":"Navy Faction",
"iconID":"0",
"hasTypes":"1",
"leaf":true
}
]
}
]
}
]
}
],
"metaData":{
"rootProperty":"records"
},
"num_sent":2
}
问题是我使用了“记录”作为根。如果您更改根目录的名称,该名称也会更改查找子目录的位置,因此每个项目都应该有一个包含其子目录的“records”属性,而不是一个“children”属性。是的,它被写入。查看“读取嵌套数据”部分。感谢您抽出时间为其他人留下答案:)