Initialization
Download the DHTMLX Tree package:
Follow these steps to initialize DHTMLX Tree in an application:
- Include source files
- Create a container
- Initialize Tree with the object constructor
- Load data into Tree
<!DOCTYPE html>
<html>
<head>
<title>How to Start with DHTMLX Tree</title>
<script type="text/javascript" src="../../codebase/tree.js"></script>
<link rel="stylesheet" href="../../codebase/tree.css">
</head>
<body>
<div id="tree_container"></div>
<script>
// creating DHTMLX Tree
const tree = new dhx.Tree("tree_container",{
// config options
});
</script>
</body>
</html>
Include source files
Unpack the downloaded package into your project folder.
Create an HTML file and add the paths to the library JS and CSS files in its header. You can use DHTMLX Tree standalone or as part of the Suite library.
If you use DHTMLX Tree standalone, include these JS/CSS files:
tree.jstree.css
<script type="text/javascript" src="../../codebase/tree.js"></script>
<link rel="stylesheet" href="../../codebase/tree.css">
If you use DHTMLX Tree as part of the Suite package, include these JS/CSS files:
suite.jssuite.css
<link type="text/css" href="../codebase/suite.css">
<script src="../codebase/suite.js" type="text/javascript"></script>
Create a container
Add a container for Tree and give it an id, for example tree_container:
<div id="tree_container"></div>
Initialize Tree
Initialize Tree with the dhx.Tree object constructor. The constructor takes two parameters:
- The HTML container for Tree. You created it in the previous step.
- An object with configuration properties (optional). If you omit this argument, Tree uses the default settings.
// creating DHTMLX Tree
const tree = new dhx.Tree("tree_container", {
checkbox: true
});
Configuration properties
The Tree API overview article describes the properties you can specify to adapt Tree to your needs.
Load data into Tree
The Data loading article describes how to load data into Tree.