我想使用ExtJS4創建TreePanel。所以,我要送JSON到代理讀者已經格式如下ExtJS4如何從JSON設置TreePanels根節點
{"text":"en","children":
{"text":"/","children":[
{"text":"/page","children":[
{"text":"/page/new","children":[],"leaf":true,"expanded":false},
{"text":"/page/remove","children":[],"leaf":true,"expanded":false}
],"leaf":false,"expanded":false},
{"text":"/home","children":[],"leaf":true,"expanded":false}
],"leaf":false,"expanded":true}
}
如何做我必須配置我的店,如果我想"en"
節點成爲我的根節點。
Ext.define('Example.store.WebItems', {
extend: 'Ext.data.TreeStore',
model: 'Example.model.Item',
proxy: {
type: 'ajax',
api: {
read : 'some/url',
},
reader: {
type: 'json',
root: 'children' // Is this correct?
}
},
root: // What should I write here?
});
當我定義TreeStore
的根爲root: 'My Root'
這將增加新的根,但我想使用JSON定義的根。所以我的問題是:
- 如何從JSON使用根節點,而不是定義它manualy?
- 我是否還必須在代理讀取器和TreeStore中定義根節點?
感謝您的回答。我只想補充一點,Ext.tree.Panel的屬性'rootVisible'必須設置爲'false'。否則,不會加載樹。 – kurochenko
將rootVisible設置爲false是我正在尋找的祕密......謝謝! – prototype