$("#actionTreeContent").css({
left: deptOffset.left - 26 + "px",
top: deptOffset.top + "px"
}).slideDown("fast");
$('#actionTypeTree').css({width: deptObj.outerWidth() + "px"});
var zTree = $.fn.zTree.getZTreeObj("actionTypeTree");
var node = zTree.getNodeByParam("id", $('#actionTypeId').val(), null);
zTree.selectNode(node);
$("body").bind("mousedown", onBodyDownByActionType);
}
});
}
/*
* Body鼠标按下事件回调函数
*/
function onBodyDownByActionType(event) {
if (event.target.id.indexOf('switch') == -1) {
hideActionTypeMenu();
}
}
/*
* 隐藏点击事件Tree
*/
function hideActionTypeMenu() {
$("#actionTreeContent").fadeOut("fast");
$("body").unbind("mousedown", onBodyDownByActionType);
}
方式二:使用easyui
前端代码:
<div class="form-group">
<label>点击事件:</label>
<input id="actionTypeId2" name="actionTypeId2" class="form-control" />
</div> js代码:
$("#actionTypeId2").combotree({
url: localStorage.getItem("adminPath") + '/touch/typeTable/getActionList?businessTypeId=2',
textField:'name',
onClick: function (node) {
$("#actionTypeId").val(node.id);
},
onSelect: function (node) {
/**
* 当选中该节点时展开该节点,同时关闭其他节点
*/
if (node.state == "closed") {
$(this).tree('expand', node.target);
}
else {
var isLeaf = $(this).tree('isLeaf', node.target);
if (!isLeaf) {
$(this).tree("collapse", node.target);
}
}
}
});总结
以上所述是小编给大家介绍的Easyui和zTree两种方式分别实现树形下拉框,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!










