Different loading modes

To load the tree from JSON you need to have a JSON object or a file.


reload from JSON object (textarea)
load from external JSON file

Format of JSON.
{ id:ID, attributes.... , item:[ array of child objects ]}

</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
	<title> Different loading modes</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);
			myTree.parse({id:0, item:[{id:1,text:"1111"},{id:2, text:"222222", item:[{id:"21", text:"child"}]},{id:3,text:"3333"}]}, "json")
		}
	</script>
</head>
<body onload="doOnLoad()">
	<h1>Different loading modes</h1>
	<p>To load the tree from JSON you need to have a JSON object or a file. </p>
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" class="tree_demo_samples"></div>
			</td>
			<td rowspan="2" style="padding-left:25px" valign="top">
				<textarea id="a12" rows="8" cols="42" style="width:350px; height:200px">
{id:0,item:[
	{id:1,text:"1111"},
	{id:2, text:"222222",item:[
		{id:"21", text:"child"}]},
	{id:3,text:"3333"}
]}
				</textarea><br/>
				<a href="javascript:void(0)" onClick="myTree.deleteChildItems(0);eval('var z='+document.getElementById('a12').value); myTree.parse(z, 'json');"> reload from JSON object (textarea)</a> <br/>
				<a href="javascript:void(0)" onClick="myTree.deleteChildItems(0); myTree.load('../common/data.json','json');">load from external JSON file</a>
			</td>
		</tr>
	</table>
	<p>Format of JSON.
	<br>{ id:ID, attributes.... , item:[ array of child objects ]}</p>
</body>
</html>

Documentation

Check documentation to learn how to use the components and easily implement them in your applications.