标签:
<ul id="treeDemo" class="ztree">
</ul>
$(function () {
$.fn.zTree.init($("#treeDemo"), setting);
})
//#region 树
var setting = {
async: {
enable: true,
url: GetUrl(‘/Dept/GetDeptTree‘),
dataFilter: filter
},
data: {
simpleData:
{
enable: true
}
},
callback: {
onClick: onClick
}
};
function filter(treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i = 0, l = childNodes.length; i < l; i++) {
childNodes[i].name = childNodes[i].name.replace(/\.n/g, ‘.‘);
}
return childNodes;
}
//树点击事件
function onClick(event, treeId, treeNode, clickFlag) {
import_Name = treeNode.name;
import_id = treeNode.id;
$("#hidTreeDept").val(treeNode.id);
$("#hidTreeDeptName").val(treeNode.name);
searchItem = { DeptID: $("#hidTreeDept").val() };
DataBind();
}
//#endregion
MVC部门树的实现 http://www.ztree.me/v3/api.php
标签:
原文地址:http://www.cnblogs.com/treeleaf/p/4463633.html