Building tree with script
To build a tree with opened or closed parent nodes click on an appropriate action link.
Build opened tree Build closed tree |
</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
<title>Building tree with script</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<link rel="stylesheet" type="text/css" href="../common/demo_style.css"/>
<script>
var myTree;
function doOnLoad(){
myTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
myTree.setImagePath("../../../skins/web/imgs/dhxtree_web/");
myTree.enableDragAndDrop(true);
}
function buildIt(){
myTree.deleteChildItems(0);
myTree.insertNewChild(0,1,"Root 1");
myTree.insertNewChild(1,11,"Child 1-1");
myTree.insertNewChild(1,12,"Child 1-2");
myTree.insertNewChild(1,13,"Child 1-3");
myTree.insertNewChild(0,2,"Root 2");
myTree.insertNewChild(2,21,"Child 2-1");
myTree.insertNewChild(2,22,"Child 2-2");
myTree.insertNewChild(2,23,"Child 2-3");
myTree.insertNewChild(0,3,"Root 3");
myTree.insertNewChild(3,31,"Child 3-1");
myTree.insertNewChild(3,32,"Child 3-2");
myTree.insertNewChild(3,33,"Child 3-3");
}
function buildIt2(){
myTree.deleteChildItems(0);
myTree.insertNewChild(0,1,"Root 1");
myTree.insertNewChild(0,2,"Root 2");
myTree.insertNewChild(0,3,"Root 3");
myTree.openOnItemAdding(false);
myTree.insertNewChild(1,11,"Child 1-1");
myTree.insertNewChild(1,12,"Child 1-2");
myTree.insertNewChild(1,13,"Child 1-3");
myTree.insertNewChild(2,21,"Child 2-1");
myTree.insertNewChild(2,22,"Child 2-2");
myTree.insertNewChild(2,23,"Child 2-3");
myTree.insertNewChild(3,31,"Child 3-1");
myTree.insertNewChild(3,32,"Child 3-2");
myTree.insertNewChild(3,33,"Child 3-3");
myTree.openOnItemAdding(true);
}
</script>
</head>
<body onload="doOnLoad()">
<h1>Building tree with script</h1>
<p>To build a tree with opened or closed parent nodes click on an appropriate action link.</p>
<table>
<tr>
<td>
<div id="treeboxbox_tree" class="tree_demo_samples"></div>
</td>
<td rowspan="2" style="padding-left:25px" valign="top">
<a href='#' onclick='buildIt();'>Build opened tree</a><br/>
<a href='#' onclick='buildIt2();'>Build closed tree</a>
</td>
</tr>
</table>
<div id="out_zone"></div>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.