DHTMLX Docs & Samples Explorer

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
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxtree.css">
   <script  src="../../codebase/dhtmlxcommon.js"></script>
   <script  src="../../codebase/dhtmlxtree.js"></script>
   <script  src="../../codebase/ext/dhtmlxtree_json.js"></script>   
   
   <table>
 <tr>
     <td>
        <div id="treeboxbox_tree" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
     </td>
     <td rowspan="2" style="padding-left:25" valign="top">
<textarea id="a12" rows="8" cols="40">1,0,1111
2,0,2222
3,0,3333
4,2,child</textarea>
<br/>
   <a href="javascript:void(0)" onClick="tree.deleteChildItems(0);  tree.loadCSVString(document.getElementById('a12').value);">
reload from CSV string (textarea, make sure that items are separated with CRs)
</a>         <br/>
<a href="javascript:void(0)" onClick="tree.deleteChildItems(0); tree.loadCSV('../common/data.csv');">
load from external CSV file
</a>
     </td>
  </tr>
   </table>
 
 
<script>
var tree = new dhtmlXTreeObject('treeboxbox_tree', '100%', '100%', 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("../../codebase/imgs/csh_bluebooks/");
tree.enableDragAndDrop(true);
tree.loadCSVString("1,0,1111\n2,0,2222\n3,0,3333\n4,2,child");
</script>