EasyUI ComboTree 全球观热点

清一色财经   2023-05-04 20:11:46


(资料图片)

设置栏目树选中无效,在用户点击勾选复选框之前触发,返回false可以取消选择动作。

functionuserRole(type){$("#user_tree_role").tree({url:"${request.contextPath}/menu/tree",onLoadSuccess:function(e,node){treeChecked(node,type);},onBeforeCheck:function(e,checked){//设置栏目树选中无效,在用户点击勾选复选框之前触发,返回false可以取消选择动作/*if(type=="new"){if(e.attributes.virtualColumn=="true"){returnfalse;}}else{if(e.attributes.virtualColumn=="true"||e.id==$("#column_tree").tree("getSelected").id){returnfalse;}}*/}});$("#tree_type").val(type);$("#user_dialog_role").dialog("open");}
functiontreeChecked(node,type){//遍历节点,符合要求的更新对应节点varmenuVal="";if(type=="add"){menuVal=$("#menuID").val()+",";}else{menuVal=$("#menuID_edit").val()+",";}$.each(node,function(idx,val){if(valinstanceofObject){varnodes=$("#user_tree_role").tree("find",val.id);if(nodes!=null){if(menuVal.indexOf(val.id+",")!=-1){//选中已勾选的栏目$("#user_tree_role").tree("update",{target:nodes.target,checked:true});}}}if(val.children){treeChecked(val.children,type);//如果还有子节点则继续遍历}});}functiongetChecked(){varnodes=$("#user_tree_role").tree("getChecked");vars="";varv="";for(vari=0;i

【本文是清一色专栏作者张勇波的原创文章,转载请通过清一色获取作者授权】