zTree树形目录之id与pId存在上下级关系使用方法

官网接口文档:http://www.treejs.cn/v3/api.php

html代码块

<ul class="ztree" id="treeDemo"> </ul>

javascript代码块

var setting = {data: {simpleData: {enable: true}}};
var zNodes =[
	{ id:1, pId:0, name:"根 Root", open:true},
	{ id:11, pId:1, name:"父节点 1-1", open:true},
	{ id:111, pId:11, name:"叶子节点 1-1-1"},
	{ id:112, pId:11, name:"叶子节点 1-1-2"},
	{ id:113, pId:11, name:"叶子节点 1-1-3"},
	{ id:114, pId:11, name:"叶子节点 1-1-4"},
	{ id:12, pId:1, name:"父节点 1-2", open:true},
	{ id:121, pId:12, name:"叶子节点 1-2-1"},
	{ id:122, pId:12, name:"叶子节点 1-2-2"},
	{ id:123, pId:12, name:"叶子节点 1-2-3"},
	{ id:124, pId:12, name:"叶子节点 1-2-4"},
	{ id:13, pId:1, name:"父节点 1-3", open:true},
	{ id:131, pId:13, name:"叶子节点 1-3-1"},
	{ id:132, pId:13, name:"叶子节点 1-3-2"},
	{ id:133, pId:13, name:"叶子节点 1-3-3"},
	{ id:134, pId:13, name:"叶子节点 1-3-4"}
];
$(document).ready(function(){
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
正在加载评论...