Jquery EasyUI Combotree和 EasyUI tree展开所有父节点和获取完整路径
Jquery EasyUI Combotree展开所有父节点
Jquery EasyUI Combotree获取树完整路径
Jquery EasyUI tree展开所有父节点
Jquery EasyUI tree获取完整路径
================================
©Copyright 蕃薯耀 2018年5月11日
效果如下:
1、默认显示完整路径
2、默认根据叶子节点的值赋值,并从该子结点逐层向上展开所有父结点
使用方法见:http://fanshuyao.iteye.com/blog/2420530 中的方式四
/** * 根据叶子节点展开所有父节点 * @param treeObj 树对象,(combotree的树对象获取:var treeObj = comboObj.combotree("tree");) * @param node 叶子节点 */ function expandParent(treeObj, node){ var parentNode = treeObj.tree("getParent", node.target); if(parentNode != null && parentNode != "undefined"){ treeObj.tree("expand", parentNode.target); expandParent(treeObj, parentNode); } }; /** * tree初始化赋值并展开所有父节点 * @param treeObj 树对象 * @param leafValue 叶子节点的值 */ function treeInitValueAndExpand(treeObj, leafValue){ var nodesChecked = treeObj.tree("getChecked");//获取选中的值 if(nodesChecked.length > 0){ for(var i=0; i<nodesChecked.length; i++){ expandParent(treeObj, nodesChecked[i]); } } }; /** * 根据叶子节点选中的值,获取树整个路径的名称 * @param treeObj 树对象,(combotree的树对象获取:var treeObj = comboObj.combotree("tree");) * @param node 叶子节点 */ function getTreePathNames(treeObj, node){ var pathName = node.text; var parentNode = treeObj.tree("getParent", node.target); if(parentNode != null && parentNode != "undefined"){ //此处为父节点的名称 + 子节点名称 pathName = getTreePathNames(treeObj, parentNode) + " > " + pathName; } return pathName; }; /** * 根据叶子节点选中的值,获取树整个路径的名称 * @param combotreeId 唯一ID * @param leafValue 叶子节点的值 */ function getCombotreePathNames(combotreeId, leafValue){ var combotreeObj = $("#"+combotreeId); var treeObj = combotreeObj.combotree("tree"); var nodesChecked = treeObj.tree("getChecked");//获取选中的值 var pathName = ""; if(nodesChecked.length > 0){ for(var i=0; i<nodesChecked.length; i++){ pathName += getTreePathNames(treeObj, nodesChecked[i]); } } return pathName; }; /** * combotree初始化赋值并展开所有父节点 * @param combotreeId 唯一ID * @param leafValue 叶子节点的值 */ function combotreeInitValueAndExpand(combotreeId, leafValue){ var combotreeObj = $("#"+combotreeId); var treeObj = combotreeObj.combotree("tree"); combotreeObj.combotree("setValue", leafValue);//赋值 treeInitValueAndExpand(treeObj, leafValue); };
(如果你觉得文章对你有帮助,欢迎捐赠,^_^,谢谢!)
================================
©Copyright 蕃薯耀 2018年5月11日
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17