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()