easyui combotree複選框多選只能選擇葉子節點

<input class="easyui-combotree" id="chooseOrg" style="width:190px;height:28px;"
						data-options="cascadeCheck:false,onlyLeafCheck:true,editable:true,multiple:true,checkbox:true,prompt:'請選擇',url:'<%=path%>/client/treeList',method:'get',required:true,panelHeight:'300',onBeforeSelect:function(node){checkLeaf(node);},onClick:function(node){beforeCheck(node);}"/>
					

需要設置的屬性

cascadeCheck:false
onlyLeafCheck:true
multiple:true
checkbox:true

javascript代碼

//只允許選擇葉子結點
function checkLeaf(node){
	console.log("checkLeaf");
	var t = $(this).tree;
	var isLeaf = t('isLeaf',node.target);
	if(!isLeaf){
		return false;
	}
}
// 只允許勾選葉子節點
function beforeCheck(node){
	if (!$(this).tree('isLeaf', node.target)) {
		console.log("beforeCheck")
		return false;
    }

}

效果圖:
在這裏插入圖片描述

easyui關於combotree的說明文檔地址 http://www.jeasyui.net/plugins/185.html

另外一篇博客值得學習 https://blog.csdn.net/w995223851/article/details/88350060

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章