data
sets a dataset for a tree
data?: array;
Example
const data = new dhx.TreeCollection();
data.load("../common/treedata.json");
const tree = new dhx.Tree("tree_container", {data: data});
Related samples:
Each data object can have the following properties:
value | (string) the value of an item |
id | (string, number) the id of an item |
opened | (boolean) optional, defines whether an item is opened by default |
checkbox | (boolean) optional, enables/disables displaying a checkbox for a tree item |
items | (array) an array of children items |
icon | (object) allows adding custom icons for a tree item Related sample: Tree. Custom dataset icons |
const tree = new dhx.Tree("tree_container", {
data:[
{
"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.
tree.data.update("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.
tree.data.getItem("Thrillers").parent
// "Books"
tree.data.getItem("Books").parent
// "_ROOT_u1574768464563"