var setting = {
view: {
showIcon: showIconForTree,
showLine: false
},
async: {
enable: true,
url:"./getMenuUserTree.action",
autoParam:["id"],
otherParam:{"otherParam":"zTreeAsyncTest"},
dataFilter: filter
},
callback: {
onClick: zTreeOnClick
}
};
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 showIconForTree(treeId, treeNode) {
return !treeNode.isParent;
};
function zTreeOnClick(event, treeId, treeNode) {
aa(treeNode.id);
// alert(+ ", " + treeNode.name);
};
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting);
});
<ul id="treeDemo" class="ztree"></ul>
JSON格式:{"id":110000,"name":"北京市","isParent":"true"},{"id":120000,"name":"天津市","isParent":"true"},