sets a dataset for a tree

array data;


var data = new dhx.TreeCollection();
var tree = new dhx.Tree("tree", {data: data});

Related samples


Each data object can have the following properties:

  • id - (string) the id of a tree item, auto-generated if not set
  • value - (string) the value of a tree item
  • items - (array) optional, an array of children items
  • opened - (boolean) optional, defines whether an item is opened by default
  • checkbox - (boolean) optional, enables/disables displaying a checkbox for a tree item
  • icon - (object) allows adding custom icons for a tree item
    Related sample:  Custom dataset icons - DHTMLX Tree
var tree = new dhx.Tree("tree", {
            "value": "Books",
            "id": "Books",
            "opened": true,
            "checkbox": true,
            "items": [
                    "value": "Thrillers",
                    "id": "Thrillers",
                    "icon": { 
                        "folder": "fas fa-book", 
                        "openFolder": "fas fa-book-open", 
                        "file": "fas fa-file"

You can disable displaying a checkbox for a tree item via the update method of tree collection."Books", {checkbox:false});
  • parent - (string) the id of the parent of a tree item

For example, you can get the parent of an item using the getItem method of tree collection."Thrillers").parent
// "Books""Books").parent
// "_ROOT_u1574768464563"
See also
Back to top