参考原文:https://blog.csdn.net/jumtre/article/details/43233685
前台:
<tr>
<td>
<label>所属部门:</label>
</td>
<td align="left">
<label runat="server" id="lblDepartmentID"></label>
<input id="txtDepartmentID" class="easyui-combotree"
data-options="editable:false,panelHeight:260,panelWidth:390,multiple:true,checkbox:true,cascadeCheck:false,url: '/../BaseDataService.asmx/GetDepartmentTree',required:true, onCheck:function(node,checked){treeOnCheck($('#txtDepartmentID').combotree('tree'),node,checked);}" style="width: 270px;" />
<label id="lblBm" ></label>
</td>
</tr>
方法:
function treeOnCheck(tree, node) {
var parent = node;
$("#lblBm").text(parent.id);
var path1 = null;
do {
path1 = (path1 == null) ? parent.text : parent.text + "-" + path1;
var parent = tree.tree('getParent', parent.target);
} while (parent);
$("#txtDepartmentID").combotree('setValue', path1)
}
效果:
如果只显示选中的,则上述方法改为: