Skip to main content

rootId

Optional. Sets the id for the root element

rootId?: string | number;

Example

const tree = new dhx.Tree(null, {
rootId: "root"
});

By default, the root element takes the id of a Tree container.

const tree = new dhx.Tree("tree_container");
tree.data.getRoot(); -> "tree_container"

You should use the rootId property, if you render a tree in a layout cell and use the autoload option in the Tree configuration object. For example:

const layout = new dhx.Layout("layout", {
type: "space",
rows: [
{
id: "tree"
}
]
});

const ROOT_ID = "tree";
const tree = new dhx.Tree(null, {
autoload: "https://docs.dhtmlx.com/suite/backend/autoload",
rootId: ROOT_ID
});
tree.data.load(`https://docs.dhtmlx.com/suite/backend/autoload/?id=${ROOT_ID}`);

layout.getCell("tree").attach(tree);

Change log:

added in v7.0