js中:
var setting = {
view: {
showIcon: false
},
async: {
enable: true,
url: ctx+"/column/selectColumnList.do",
autoParam:["id", "name=name", "level=lv"],
otherParam:{"otherParam":"0"},
dataType: "json",
dataFilter: filter
},
data: {
simpleData: {
enable: true, // 簡單數據模式
idKey: "id",
pIdKey: "pid",
rootPId: 0
}
},
};
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;
}
jsp中:
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree"></ul>
</div>
</div>
后台需要參數:
isParent、name、id、pid
由於轉json時isParent會變成parent
所以用實體類接收時的寫法
private boolean isParent;
public boolean getIsParent() {
return isParent;
}
public void setISParent(boolean isParent) {
this.isParent = isParent;
}