Skip to content

Commit e03c749

Browse files
committed
[add] a note on using root id for treegrid/tree in a sub-row
1 parent 9a126e0 commit e03c749

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

docs/grid/api/grid_subrow_config.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,37 @@ const grid = new dhx.Grid("grid_container", {
6060
});
6161
~~~
6262

63+
:::info
64+
For Grid (in the TreeGrid mode) or Tree used in a sub-row it is important to specify the id of the root element to link data to the corresponding collection:
65+
- by using the [`rootParent`](grid/api/grid_rootparent_config.md) property for Grid in the TreeGrid mode
66+
- by using the [`rootId`](tree/api/tree_rootid_config.md) property for Tree
67+
:::
68+
69+
For example:
70+
71+
~~~jsx {8,16}
72+
grid = new dhx.Grid("grid_container", {
73+
columns: [
74+
// columns config
75+
],
76+
data: dataset,
77+
subRow: (row) => {
78+
subGrid = new dhx.Grid(null, {
79+
rootParent: "root", // Add the root id
80+
columns: [
81+
{ id: "country", header: [{ text: "Country" }] },
82+
{ id: "order_quantity", header: [{ text: "Orders" }], type: "number" },
83+
{ id: "average_check", header: [{ text: "Avg check" }], type: "number" },
84+
],
85+
data: row.data,
86+
autoWidth: true,
87+
type: "tree",
88+
});
89+
return subGrid;
90+
},
91+
});
92+
~~~
93+
6394
**Related sample:** [Grid. Row expander. Full config](https://snippet.dhtmlx.com/xdw2037t)
6495

6596
**Related article:** [Row expander](grid/configuration.md#row-expander)

docs/grid/configuration.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,37 @@ const grid = new dhx.Grid("grid_container", {
16881688

16891689
**Related sample:** [Grid. Row expander. Full config](https://snippet.dhtmlx.com/xdw2037t)
16901690

1691+
:::info
1692+
For Grid (in the TreeGrid mode) or Tree used in a sub-row it is important to specify the id of the root element to link data to the corresponding collection:
1693+
- by using the [`rootParent`](grid/api/grid_rootparent_config.md) property for Grid in the TreeGrid mode
1694+
- by using the [`rootId`](tree/api/tree_rootid_config.md) property for Tree
1695+
:::
1696+
1697+
For example:
1698+
1699+
~~~jsx {8,16}
1700+
grid = new dhx.Grid("grid_container", {
1701+
columns: [
1702+
// columns config
1703+
],
1704+
data: dataset,
1705+
subRow: (row) => {
1706+
subGrid = new dhx.Grid(null, {
1707+
rootParent: "root", // Add the root id
1708+
columns: [
1709+
{ id: "country", header: [{ text: "Country" }] },
1710+
{ id: "order_quantity", header: [{ text: "Orders" }], type: "number" },
1711+
{ id: "average_check", header: [{ text: "Avg check" }], type: "number" },
1712+
],
1713+
data: row.data,
1714+
autoWidth: true,
1715+
type: "tree",
1716+
});
1717+
return subGrid;
1718+
},
1719+
});
1720+
~~~
1721+
16911722
### Adjusting configuration of sub-rows
16921723

16931724
You can define common configuration settings of all sub-rows or provide specific options for each sub-row via the [`subRowConfig`](grid/api/grid_subrowconfig_config.md) configuration property of Grid.

0 commit comments

Comments
 (0)