var treePanel = {
id: "treeUrl",
xtype: "treepanel",
useArrows: true, // 節點睜開+,-圖標悉數改成小三角
expanded: true, // 默許睜開
region: 'west',
width: "40%",
border: false,
bodyBorder: false,
autoScroll: true,
/** 資本樹(數據集) */
store: {
storeId: 'Resources', // 數據集ID
root: { // 根節點設置
id: '1', // 根節點ID
expanded: true, // 默許睜開
text: '資本文件目次' // 根節點稱號
},
proxy: { // 接見代辦
type: 'ajax', // 範例異步
api: {
read: 'catalog/tree?type=fpd'
}
}
},
/** 監聽器 */
listeners: {
render: function () {
if (JSON.stringify(movementChild.select) != "{}") {
var _url = movementChild.select.localUrl.split("/");
var childUrl = _url.pop()
// 父節點id
var parentUrl = _url.join("/")
this.expandPath(parentUrl, 'id');
var myThis = this;
var num = 0;
var time = setInterval(function () {
num++;
if (myThis.getSelectionModel().select(myThis.getStore().getNodeById(childUrl)) != undefined || num > 5) {
clearInterval(time)
} else {
myThis.getSelectionModel().select(myThis.getStore().getNodeById(childUrl))
}
}, 100)
me.treeAjax(movementChild,movementChild.select,"render")
}
},
itemclick: function (_this, _record) {
// 清空參數
if (_record.data.leaf) {
movementChild.select["localUrl"] = Ext.getCmp("leftresource").getController().getIdPath(_record);
movementChild.select["serverPath"] = _record.data.node.path;
movementChild.select["text"] = _record.data.text;
//點擊的時刻依據途徑查找參數
me.treeAjax(movementChild,_record,"click")
}
},
}
},
},
treepanel 默許睜開第一個節點
this.getRootNode().firstChild.expand()