Skip to content

Commit 25ad596

Browse files
authored
Merge pull request #59 from DHTMLX/complete-grid-subrow-guides-4850
[add] a note on using root id for treegrid/tree in a sub-row
2 parents 265e8d4 + bf2bfb4 commit 25ad596

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

docs/grid/api/grid_subrow_config.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,36 @@ const grid = new dhx.Grid("grid_container", {
6464
});
6565
~~~
6666

67+
:::info
68+
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:
69+
- by using the [`rootParent`](grid/api/grid_rootparent_config.md) property for Grid in the TreeGrid mode
70+
- by using the [`rootId`](tree/api/tree_rootid_config.md) property for Tree
71+
:::
72+
73+
For example:
74+
75+
~~~jsx {8,16}
76+
const grid = new dhx.Grid("grid_container", {
77+
columns: [
78+
// columns config
79+
],
80+
data: dataset,
81+
subRow: (row) => (
82+
new dhx.Grid(null, {
83+
rootParent: "root", // Add the root id
84+
columns: [
85+
{ id: "country", header: [{ text: "Country" }] },
86+
{ id: "order_quantity", header: [{ text: "Orders" }], type: "number" },
87+
{ id: "average_check", header: [{ text: "Avg check" }], type: "number" },
88+
],
89+
data: row.data,
90+
autoWidth: true,
91+
type: "tree",
92+
})
93+
),
94+
});
95+
~~~
96+
6797
**Related sample:** [Grid. Row expander. Full config](https://snippet.dhtmlx.com/xdw2037t)
6898

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

docs/grid/configuration.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,36 @@ const grid = new dhx.Grid("grid_container", {
22172217

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

2220+
:::info
2221+
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:
2222+
- by using the [`rootParent`](grid/api/grid_rootparent_config.md) property for Grid in the TreeGrid mode
2223+
- by using the [`rootId`](tree/api/tree_rootid_config.md) property for Tree
2224+
:::
2225+
2226+
For example:
2227+
2228+
~~~jsx {8,16}
2229+
const grid = new dhx.Grid("grid_container", {
2230+
columns: [
2231+
// columns config
2232+
],
2233+
data: dataset,
2234+
subRow: (row) => (
2235+
new dhx.Grid(null, {
2236+
rootParent: "root", // Add the root id
2237+
columns: [
2238+
{ id: "country", header: [{ text: "Country" }] },
2239+
{ id: "order_quantity", header: [{ text: "Orders" }], type: "number" },
2240+
{ id: "average_check", header: [{ text: "Avg check" }], type: "number" },
2241+
],
2242+
data: row.data,
2243+
autoWidth: true,
2244+
type: "tree",
2245+
})
2246+
),
2247+
});
2248+
~~~
2249+
22202250
### Adjusting configuration of sub-rows
22212251

22222252
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)