<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> ZTREE DEMO - Simple Data</TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../css/demo.css" type="text/css">
<link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
<!-- <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>-->
<SCRIPT type="text/javascript">
<!--
var setting = {
data: {
simpleData: {
enable: true
}
}
};
var zNodes =[
{ id:1, pId:0, name:"父节点1 - 展开", open:true},
{ id:11, pId:1, name:"父节点11 - 折叠"},
{ id:12, pId:1, name:"叶子节点111"},
{ id:13, pId:1, name:"叶子节点112"},
{ id:2, pId:0, name:"父节点1 - 展开", open:true},
{ id:21, pId:1, name:"父节点11 - 折叠"},
{ id:22, pId:1, name:"叶子节点111"},
{ id:23, pId:1, name:"叶子节点112"},
{ id:3, pId:0, name:"父节点1 - 展开", open:true},
{ id:31, pId:1, name:"父节点11 - 折叠"},
{ id:32, pId:1, name:"叶子节点111"},
{ id:33, pId:1, name:"叶子节点112"},
];
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
//-->
</SCRIPT>
</HEAD>
<BODY>
<h1>最简单的树 -- 简单 JSON 数据</h1>
<h6>[ 文件路径: core/simpleData.html ]</h6>
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree"></ul>
</div>
</div>
<input type="button" value="动态增加树节点" οnclick="addTreeNode()">
<input type="button" value="动态删除树节点" οnclick="deleteTreeNode()">
</BODY>
</HTML>
<script>
var i = 111;
function addTreeNode(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
var treeNode = zTree.getNodeByParam("id",3,null);
zTree.addNodes(treeNode, {id:i++, pId:3,name:"ljj"});
}
function deleteTreeNode(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
var treeNode = zTree.getNodeByParam("id", --i, null);
zTree.removeNode(treeNode);
}
</script>
<HTML>
<HEAD>
<TITLE> ZTREE DEMO - Simple Data</TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../css/demo.css" type="text/css">
<link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
<!-- <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>-->
<SCRIPT type="text/javascript">
<!--
var setting = {
data: {
simpleData: {
enable: true
}
}
};
var zNodes =[
{ id:1, pId:0, name:"父节点1 - 展开", open:true},
{ id:11, pId:1, name:"父节点11 - 折叠"},
{ id:12, pId:1, name:"叶子节点111"},
{ id:13, pId:1, name:"叶子节点112"},
{ id:2, pId:0, name:"父节点1 - 展开", open:true},
{ id:21, pId:1, name:"父节点11 - 折叠"},
{ id:22, pId:1, name:"叶子节点111"},
{ id:23, pId:1, name:"叶子节点112"},
{ id:3, pId:0, name:"父节点1 - 展开", open:true},
{ id:31, pId:1, name:"父节点11 - 折叠"},
{ id:32, pId:1, name:"叶子节点111"},
{ id:33, pId:1, name:"叶子节点112"},
];
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
//-->
</SCRIPT>
</HEAD>
<BODY>
<h1>最简单的树 -- 简单 JSON 数据</h1>
<h6>[ 文件路径: core/simpleData.html ]</h6>
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree"></ul>
</div>
</div>
<input type="button" value="动态增加树节点" οnclick="addTreeNode()">
<input type="button" value="动态删除树节点" οnclick="deleteTreeNode()">
</BODY>
</HTML>
<script>
var i = 111;
function addTreeNode(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
var treeNode = zTree.getNodeByParam("id",3,null);
zTree.addNodes(treeNode, {id:i++, pId:3,name:"ljj"});
}
function deleteTreeNode(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
var treeNode = zTree.getNodeByParam("id", --i, null);
zTree.removeNode(treeNode);
}
</script>