Home > Web Front-end > JS Tutorial > body text

JQuery写动态树示例代码_jquery

WBOY
Release: 2016-05-16 17:27:33
Original
1034 people have browsed it
复制代码 代码如下:

// 业务类型树
var settingOther = {
edit: {
enable: false
},
// 异步加载树
async: {
enable: true,
url:"initCoagencyTree.action",
autoParam:["id", "name=n"],
otherParam:{"otherParam":"zTreeAsyncTest"},
dataFilter: filter
},
// 简单数据格式
data: {
simpleData: {
enable: true
}
},
// 回调函数
callback: {
beforeClick: beforeClick,
onClick: onClick
}
};
// 鼠标事件
function beforeClick(treeId, treeNode, clickFlag) {
// 普通选中
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{
// 取消选中 把值置空
$("#coagencyId").attr("value",null);
$("#parentId").attr("value",null);
}
return (treeNode.click != false);
}
// 鼠标解除节点的方法
function onClick(event, treeId, treeNode, clickFlag) {
// 默认执行的方法 显示节点的详细信息
parent.showCoagencyDetail();
}
// 异步加载需要是函数
function filter(treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i=0; ichildNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
}
return childNodes;
}
// 异步加载需要是函数
function beforeAsync(treeId, treeNode) {
return treeNode ? treeNode.level }
// 初始化树
$(document).ready(function(){
$.fn.zTree.init($("#coagencyTree"),settingOther);
});








    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!