我在 extjs4 工作。我的树面板视图为-
Ext.define('Balaee.view.qb.qbquestion.tree1', {
extend: 'Ext.tree.Panel',
title: 'Simple Tree',
width: 200,
height: 150,
alias : 'widget.tree1',
//store: 'qb.qbquestioncomplexityStore',
rootVisible: true,
renderTo: Ext.getBody()
});
在控制器中,我创建了静态存储。并将其绑定到此视图。代码如下-
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "algebra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});
var bchart=Ext.create('Balaee.view.qb.qbquestion.tree1',{
store:store
});
var comp=Ext.getCmp('QuestionView');
comp.removeAll();
comp.add(bchart);
它工作正常。实际上它的静态商店。我想为 json- 创建树面板
{"data":[{"Maincategory":"Main","maincategoryId":"1","Subcategory":{"subcategory":"GK","categoryId":"2"},{"subcategory":"History","categoryId":"3"},{"subcategory":"Geography","categoryId":"4"}]},{"Maincategory":"GK","maincategoryId":"2","Subcategory":[{"subcategory":"environment","categoryId":"5"}]},{"Maincategory":"History","maincategoryId":"3","Subcategory":[{"subcategory":"civics","categoryId":"7"}]},{"Maincategory":"Geography","maincategoryId":"4","Subcategory":[{"subcategory":"India","categoryId":"8"}]},{"Maincategory":"environment","maincategoryId":"5","Subcategory":[]}]}
那么我需要在这个 json 中做哪些修改呢?我需要换店吗?请有人可以指导我