JQuery 동적 트 리 예제 코드 쓰기

2280 단어 JQuery동적 트 리
 
//
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; i<childNodes.length; i++) {
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
}
return childNodes;
}
//
function beforeAsync(treeId, treeNode) {
return treeNode ? treeNode.level < 5 : true;
}
//
$(document).ready(function(){
$.fn.zTree.init($("#coagencyTree"),settingOther);
});
</SCRIPT>
<!-- id -->
<s:hidden name="coagencyForm.coagencyId" id="coagencyId"/>
<!-- id -->
<s:hidden name="coagencyForm.parentId" id="parentId"/>
<div class="zTreeDemoBackground left">
<ul id="coagencyTree" class="ztree" style="height: 640px"></ul>
</div>

좋은 웹페이지 즐겨찾기