I am trying to create a TreePanel that loads all its items (and their children) in a single request at creation. From everything I read if items have a "children" property they shouldn't attempt to load children again when expanded, however mine do.
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
}
]
}
});
A sample bit of JSON as received from backend/market.php?a=marketGroupTree is:
{
"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
}
The problem turned out to be the fact that I used "records" as the root. It appears that if you change the name of the root that also changes where children are looked for so each item should have a "records" property with its children, not a "children" one.