// Business type tree
var settingOther = {
edit: {
enable: false
},
// Asynchronous loading tree
async: {
enable: true,
url:"initCoagencyTree.action",
autoParam :["id", "name=n"],
otherParam:{"otherParam":"zTreeAsyncTest"},
dataFilter: filter
},
// Simple data format
data: {
simpleData: {
enable: true
}
},
// callback function
callback: {
beforeClick: beforeClick,
onClick: onClick
}
};
//Mouse event
function beforeClick(treeId, treeNode, clickFlag) {
//Normal selection
if(clickFlag==1){
parent.document.getElementById("coagencyId").value=treeNode.id;
parent.document.getElementById("parentId").value=treeNode.pId;
parent.document.getElementById("name") .value=treeNode.name;
$("#coagencyId").attr("value",treeNode.id);
$("#parentId").attr("value",treeNode.pId) ;
}else{
// Uncheck and leave the value blank
$("#coagencyId").attr("value",null);
$("#parentId").attr ("value",null);
}
return (treeNode.click != false);
}
// Method to remove the node with the mouse
function onClick(event, treeId, treeNode , clickFlag) {
// The default execution method displays the detailed information of the node
parent.showCoagencyDetail();
}
// Asynchronous loading needs to be the function
function filter(treeId, parentNode , childNodes) {
if (!childNodes) return null;
for (var i=0; i
childNodes[i].name = childNodes[i].name .replace(/.n/g, '.');
}
return childNodes;
}
// Asynchronous loading needs to be a function
function beforeAsync(treeId, treeNode) {
return treeNode ? treeNode.level < 5 : true;
}
//Initialize tree
$(document).ready(function(){
$.fn.zTree.init( $("#coagencyTree"),settingOther);
});