Loading from CSV

This type of loading tree data presupposes that the user should have CSV represented as a string or a file.


reload from CSV string (textarea, make sure that items are separated with CRs)
load from external CSV file

Format of CSV.
A tree item is represented with three values - id, parent_id, text. The order of rows in CSV doesn't matter.

</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
	<title>Loading from CSV</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("1,0,1111\n2,0,2222\n3,0,3333\n4,2,child", "csv");
		}
	</script>
</head>
<body onload="doOnLoad()">
	<h1>Loading from CSV</h1>
	<p>This type of loading tree data presupposes that the user should have CSV represented as a string 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="40" style="width:250px">1,0,t 1111
2,0,t 2222
3,0,t 3333
4,2,t child</textarea>
				<br/>
				<a href="javascript:void(0)" onClick="myTree.deleteChildItems(0); myTree.parse(document.getElementById('a12').value, 'csv');">
					reload from CSV string (textarea, make sure that items are separated with CRs)
				</a>
				<br/>
				<a href="javascript:void(0)" onClick="myTree.deleteChildItems(0); myTree.load('../common/data.csv', 'csv');">
					load from external CSV file
				</a>
			</td>
		</tr>
	</table>
	<p>Format of CSV.
	<br>A tree item is represented with three values - id, parent_id, text. The order of rows in CSV doesn't matter.</p>
</body>
</html>

Documentation

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