Jquery EasyUI Combotree根據選中的值展開全部父節點 node
Jquery EasyUI Combotree 展開父節點,ui
Jquery EasyUI Combotree根據子節點選中的值,展開前面全部父節點,this
Jquery EasyUI Combotree獲取選中的值url
================================spa
©Copyright 蕃薯耀 2018年5月7日插件
http://www.cnblogs.com/fanshuyao/code
1、Combotree獲取父節點的方法getParent,這實際上是繼承來自tree插件對象
- Name Parameter Description
- getParent target Get the parent node,
- the target parameter indicate the node DOM object.
Tree獲取父節點:blog
- $("#treeId").tree("getParent", node.target);
Combotree獲取父節點:繼承
- var treeObj = $("#combotreeId").combotree("tree");
- var parentNode = treeObj.tree("getParent", node.target);
2、Combotree獲取選中的值
- var treeObj = $("#combotreeId").combotree("tree");
- var nodesChecked = treeObj.tree("getChecked");
3、展開父節點
- $("#treeId").tree("expand", node.target);
4、根據葉子節點選中的值,展開全部父節點
展開全部父節點的方法(遞歸展開父節點):
- function expandParent(treeObj, node){
- var parentNode = treeObj.tree("getParent", node.target);
- if(parentNode != null && parentNode != "undefined"){
- treeObj.tree("expand", parentNode.target);
- expandParent(treeObj, parentNode);
- }
- };
具體使用以下:
- $("#cmm_code_id").combotree({
- multiple: true,
- required : true,
- checkbox : true,
- onlyLeafCheck : true,
- url : "${pageContext.request.contextPath}/xxx",
- onBeforeSelect : function(node){
- $(this).tree("check", node.target);
- return false;
- },
- onBeforeCheck : function(node, checked){
- if(checked){
- var nodes = $(this).tree("getChecked");
- if(nodes.length > 0){
- for(var i=0; i<nodes.length; i++){
- $(this).tree("uncheck", nodes[i].target);
- }
- }
- }
- },
- onLoadSuccess : function(node, data){
- var cmm_code_id_value = "${buildingNaming.cmm_code_id}";
- if(cmm_code_id_value != null && $.trim(cmm_code_id_value) != ""){
- var comboObj = $("#cmm_code_id");
- var treeObj = comboObj.combotree("tree");
-
- comboObj.combotree("setValue", cmm_code_id_value);
- var nodesChecked = treeObj.tree("getChecked");
- if(nodesChecked.length > 0){
- for(var i=0; i<nodesChecked.length; i++){
- expandParent(treeObj, nodesChecked[i]);
- }
- }
- }
- }
- });
================================
©Copyright 蕃薯耀 2018年5月7日
http://www.cnblogs.com/fanshuyao/