当前位置: 首页 > 后端技术 > Node.js

extjs6.0treepanelsettingexpandandsetselected

时间:2023-04-03 17:18:19 Node.js

vartreePanel={id:"treeUrl",xtype:"treepanel",useArrows:true,//将节点的+和-图标展开为小三角形expanded:true,//默认展开region:'west',width:"40%",border:false,bodyBorder:false,autoScroll:true,/**资源树(数据集)*/store:{storeId:'Resources',//数据集IDroot:{//根节点配置id:'1',//根节点IDexpanded:true,//默认展开文本:'资源文件目录'//根节点名称},proxy:{//访问代理类型:'ajax',//异步类型api:{read:'catalog/tree?type=fpd'}}},/**监听器*/listeners:{render:function(){if(JSON.stringify(movementChild.select)!="{}"){var_url=movementChild.select.localUrl.split("/");varchildUrl=_url.pop()//父节点idvarparentUrl=_url.join("/")this.expandPath(parentUrl,'id');varmyThis=这个;变种数=0;vartime=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){//清除参数movementChild.select["serverPath"]=_record.data.node.path;movementChild.select["text"]=_record.data.text;//点击时,根据路径查找参数me.treeAjax(movementChild,_record,"click")}},}},}treepanel默认展开第一个节点this.getRootNode().firstChild.expand()