You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+109-5Lines changed: 109 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -596,20 +596,124 @@ test('grid', async () => {
596
596
597
597
#### `<TreeDataGrid />`
598
598
599
-
`TreeDataGrid` is component built on top of `DataGrid` to add row grouping. This implements the [Treegrid pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treegrid/). At the moment `TreeDataGrid` does not support `onFill` and `isRowSelectionDisabled` props
599
+
`TreeDataGrid` is a component built on top of `DataGrid` to add hierarchical row grouping. This implements the [Treegrid pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treegrid/).
600
+
601
+
**How it works:**
602
+
603
+
1. The `groupBy` prop specifies which columns should be used for grouping
604
+
2. The `rowGrouper` function groups rows by the specified column keys
605
+
3. Group rows are rendered with expand/collapse toggles
606
+
4. Child rows are nested under their parent groups
607
+
5. Groups can be expanded/collapsed by clicking the toggle or using keyboard navigation (<kbd>←</kbd>, <kbd>→</kbd>)
608
+
609
+
**Keyboard Navigation:**
610
+
611
+
- <kbd>→</kbd> (Right Arrow): Expand a collapsed group row when focused
612
+
- <kbd>←</kbd> (Left Arrow): Collapse an expanded group row when focused, or navigate to parent group
613
+
614
+
**Unsupported Props:**
615
+
616
+
The following `DataGrid` props are not supported in `TreeDataGrid`:
617
+
618
+
-`onFill` - Drag-fill is disabled for tree grids
619
+
-`isRowSelectionDisabled` - Row selection disabling is not available
620
+
621
+
**Caveats:**
622
+
623
+
- Group columns cannot be rendered under one column
624
+
- Group columns are automatically frozen and cannot be unfrozen
625
+
- Cell copy/paste does not work on group rows
600
626
601
627
##### TreeDataGridProps
602
628
603
-
###### `groupBy?: Maybe<readonly string[]>`
629
+
All [`DataGridProps`](#datagridprops) are supported except those listed above, plus the following additional props:
630
+
631
+
###### `groupBy: readonly string[]`
632
+
633
+
**Required.** An array of column keys to group by. The order determines the grouping hierarchy (first key is the top level, second key is nested under the first, etc.).
**Required.** A function that groups rows by the specified column key. Returns an object where keys are the group values and values are arrays of rows belonging to that group.
666
+
667
+
```tsx
668
+
function rowGrouper(rows:Row[], columnKey:string) {
**Note:** Unlike `DataGrid`, the `rowHeight` function receives [`RowHeightArgs<R>`](#rowheightargstrow) which includes a `type` property to distinguish between regular rows and group rows:
705
+
706
+
```tsx
707
+
function getRowHeight(args:RowHeightArgs<Row>):number {
708
+
if (args.type==='GROUP') {
709
+
return50; // Custom height for group rows
710
+
}
711
+
return35; // Height for regular rows
712
+
}
713
+
714
+
<TreeDataGridrowHeight={getRowHeight}... />
715
+
```
716
+
613
717
#### `<Row />`
614
718
615
719
The default row component. Can be wrapped via the `renderers.renderRow` prop.
0 commit comments