ztree 更新配置后重新渲染树_【问】zTree异步加载时添加父节点怎样避免再次加载整树...
該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓
具體情況是
每當我執(zhí)行add方法添加父節(jié)點的時候,都回去server端重新獲取一次樹節(jié)點信息,并加載在新增加的節(jié)點下。
頁面代碼如下
var setting1 = {
async : {
enable : true,
type : "post",
dataType : "json",
url : "/JsonAction.action?id=0099",
autoParam : [ "id", "name", "pId", "isParent", "open" ]
},
data : {
keep: {
parent: true,
leaf:true,
},
simpleData : {
enable : true,
idKey : "id",
pIdKey : "pId",
rootPId : 0
}
},
edit: {
enable: true,
showRemoveBtn: true,
showRenameBtn: true
}
};
var newCount = 1;
//增加節(jié)點
function add(e) {
var zTreeObj = $.fn.zTree.getZTreeObj("Mytree");
isParent = e.data.isParent,
nodes = zTreeObj.getSelectedNodes(),
alert("當前選中"+nodes.length+"個節(jié)點")
treeNode = nodes[0];
alert(""+treeNode)
if (treeNode) {
treeNode = zTreeObj.addNodes(treeNode, {id:(100 + newCount), pId:treeNode.id, isParent:isParent, name:"new node" + (newCount++), open:true}, false);
} else {
treeNode = zTreeObj.addNodes(null, {id : (100 + newCount),pId : 0,isParent : isParent,name : "new node" + (newCount++),open : true}, false);
}
};
// zTree 的數(shù)據(jù)屬性,深入使用請參考 API 文檔(zTreeNode 節(jié)點數(shù)據(jù)詳解)
$(document).ready(function() {
$.fn.zTree.init($("#Mytree"), setting1);
$("#addParent").bind("click", {isParent : true}, add);
$("#addLeaf").bind("click", {isParent : false}, add);
});
總結
以上是生活随笔為你收集整理的ztree 更新配置后重新渲染树_【问】zTree异步加载时添加父节点怎样避免再次加载整树...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求水仙花_500万株水仙花争相绽放,这个
- 下一篇: django 怎么加权限 静态资源目录_