Skip to content

Commit c0dd660

Browse files
committed
[add] an example on using rootId tree prop in a layout cell with autoload
1 parent f019aab commit c0dd660

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/tree/api/tree_rootid_config.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,27 @@ const tree = new dhx.Tree("tree_container");
2424
tree.data.getRoot(); -> "tree_container"
2525
~~~
2626

27-
You should use the `rootId` property, if you render a tree in a layout cell and use the [`autoload`](/tree/api/tree_autoload_config/) option in the Tree configuration object.
27+
You should use the `rootId` property, if you render a tree in a layout cell and use the [`autoload`](/tree/api/tree_autoload_config/) option in the Tree configuration object. For example:
2828

29+
~~~js
30+
const layout = new dhx.Layout("layout", {
31+
type: "space",
32+
rows: [
33+
{
34+
id: "tree"
35+
}
36+
]
37+
});
38+
39+
const ROOT_ID = "tree";
40+
const tree = new dhx.Tree(null, {
41+
autoload: "https://docs.dhtmlx.com/suite/backend/autoload",
42+
rootId: ROOT_ID
43+
});
44+
tree.data.load(`https://docs.dhtmlx.com/suite/backend/autoload/?id=${ROOT_ID}`);
45+
46+
layout.getCell("tree").attach(tree);
47+
~~~
2948

3049

3150
@changelog: added in v7.0

0 commit comments

Comments
 (0)