Skip to content

Commit 338eaad

Browse files
[DataGrid] Make row spanning feature stable (#15742)
Co-authored-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com>
1 parent 3034df3 commit 338eaad

27 files changed

+57
-59
lines changed

docs/data/data-grid/row-spanning/RowSpanning.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function RowSpanning() {
2323
showCellVerticalBorder
2424
showColumnVerticalBorder
2525
disableRowSelectionOnClick
26-
unstable_rowSpanning={enabled}
26+
rowSpanning={enabled}
2727
hideFooter
2828
sx={{
2929
'& .MuiDataGrid-row:hover': {

docs/data/data-grid/row-spanning/RowSpanning.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function RowSpanning() {
2323
showCellVerticalBorder
2424
showColumnVerticalBorder
2525
disableRowSelectionOnClick
26-
unstable_rowSpanning={enabled}
26+
rowSpanning={enabled}
2727
hideFooter
2828
sx={{
2929
'& .MuiDataGrid-row:hover': {

docs/data/data-grid/row-spanning/RowSpanningCalendar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default function RowSpanningCalendar() {
137137
<DataGrid
138138
columns={columns}
139139
rows={rows}
140-
unstable_rowSpanning
140+
rowSpanning
141141
disableRowSelectionOnClick
142142
hideFooter
143143
showCellVerticalBorder

docs/data/data-grid/row-spanning/RowSpanningCalendar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default function RowSpanningCalendar() {
148148
<DataGrid
149149
columns={columns}
150150
rows={rows}
151-
unstable_rowSpanning
151+
rowSpanning
152152
disableRowSelectionOnClick
153153
hideFooter
154154
showCellVerticalBorder

docs/data/data-grid/row-spanning/RowSpanningCalendar.tsx.preview

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<DataGrid
22
columns={columns}
33
rows={rows}
4-
unstable_rowSpanning
4+
rowSpanning
55
disableRowSelectionOnClick
66
hideFooter
77
showCellVerticalBorder

docs/data/data-grid/row-spanning/RowSpanningClassSchedule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default function RowSpanningClassSchedule() {
137137
<DataGrid
138138
columns={columns}
139139
rows={rows}
140-
unstable_rowSpanning
140+
rowSpanning
141141
disableRowSelectionOnClick
142142
hideFooter
143143
showCellVerticalBorder

docs/data/data-grid/row-spanning/RowSpanningClassSchedule.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default function RowSpanningClassSchedule() {
139139
<DataGrid
140140
columns={columns}
141141
rows={rows}
142-
unstable_rowSpanning
142+
rowSpanning
143143
disableRowSelectionOnClick
144144
hideFooter
145145
showCellVerticalBorder

docs/data/data-grid/row-spanning/RowSpanningCustom.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function RowSpanningCustom() {
1212
showColumnVerticalBorder
1313
disableRowSelectionOnClick
1414
hideFooter
15-
unstable_rowSpanning
15+
rowSpanning
1616
sx={{
1717
'& .MuiDataGrid-row:hover': {
1818
backgroundColor: 'transparent',

docs/data/data-grid/row-spanning/RowSpanningCustom.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function RowSpanningCustom() {
1212
showColumnVerticalBorder
1313
disableRowSelectionOnClick
1414
hideFooter
15-
unstable_rowSpanning
15+
rowSpanning
1616
sx={{
1717
'& .MuiDataGrid-row:hover': {
1818
backgroundColor: 'transparent',

docs/data/data-grid/row-spanning/RowSpanningCustom.tsx.preview

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
showColumnVerticalBorder
66
disableRowSelectionOnClick
77
hideFooter
8-
unstable_rowSpanning
8+
rowSpanning
99
sx={{
1010
'& .MuiDataGrid-row:hover': {
1111
backgroundColor: 'transparent',

docs/data/data-grid/row-spanning/row-spanning.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
<p class="description">Span cells across several rows.</p>
44

5-
:::warning
6-
This feature is marked as **unstable**. While you can use this feature in production, the API could change in the future.
7-
:::
8-
95
By default, each cell in a Data Grid takes up the height of one row.
106
The row spanning feature makes it possible for a cell to fill multiple rows in a single column.
117

12-
To enable, pass the `unstable_rowSpanning` prop to the Data Grid.
8+
To enable, pass the `rowSpanning` prop to the Data Grid.
139
The Data Grid will automatically merge consecutive cells with repeating values in the same column, as shown in the demo below—switch off the toggle button to see the actual rows:
1410

1511
{{"demo": "RowSpanning.js", "bg": "inline", "defaultCodeOpen": false}}

docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: React Data Grid - Migration from v7 to v8
23
productId: x-data-grid
34
---
45

@@ -54,6 +55,15 @@ Below are described the steps you need to make to migrate from v7 to v8.
5455
+const rowId = apiRef.current.getRowId(rowsLookup[id]);
5556
```
5657

58+
- The feature row spanning is now stable.
59+
60+
```diff
61+
<DataGrid
62+
- unstable_rowSpanning
63+
+ rowSpanning
64+
/>
65+
```
66+
5767
### Localization
5868

5969
- If `estimatedRowCount` is used, the text provided to the [Table Pagination](/material-ui/api/table-pagination/) component from the Material UI library is updated and requires additional translations. Check the example at the end of [Index-based pagination section](/x/react-data-grid/pagination/#index-based-pagination).

docs/data/pages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const pages: MuiPage[] = [
6262
{ pathname: '/x/react-data-grid/row-definition' },
6363
{ pathname: '/x/react-data-grid/row-updates' },
6464
{ pathname: '/x/react-data-grid/row-height' },
65-
{ pathname: '/x/react-data-grid/row-spanning', unstable: true },
65+
{ pathname: '/x/react-data-grid/row-spanning', newFeature: true },
6666
{ pathname: '/x/react-data-grid/master-detail', plan: 'pro' },
6767
{ pathname: '/x/react-data-grid/row-ordering', plan: 'pro' },
6868
{ pathname: '/x/react-data-grid/row-pinning', plan: 'pro' },

docs/pages/x/api/data-grid/data-grid-premium.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@
605605
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
606606
"default": "\"margin\""
607607
},
608+
"rowSpanning": { "type": { "name": "bool" }, "default": "false" },
608609
"scrollbarSize": { "type": { "name": "number" } },
609610
"scrollEndThreshold": { "type": { "name": "number" }, "default": "80" },
610611
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
@@ -647,7 +648,6 @@
647648
}
648649
},
649650
"unstable_listView": { "type": { "name": "bool" } },
650-
"unstable_rowSpanning": { "type": { "name": "bool" }, "default": "false" },
651651
"virtualizeColumnsWithAutoRowHeight": { "type": { "name": "bool" }, "default": "false" }
652652
},
653653
"name": "DataGridPremium",

docs/pages/x/api/data-grid/data-grid-pro.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@
543543
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
544544
"default": "\"margin\""
545545
},
546+
"rowSpanning": { "type": { "name": "bool" }, "default": "false" },
546547
"scrollbarSize": { "type": { "name": "number" } },
547548
"scrollEndThreshold": { "type": { "name": "number" }, "default": "80" },
548549
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
@@ -581,7 +582,6 @@
581582
}
582583
},
583584
"unstable_listView": { "type": { "name": "bool" } },
584-
"unstable_rowSpanning": { "type": { "name": "bool" }, "default": "false" },
585585
"virtualizeColumnsWithAutoRowHeight": { "type": { "name": "bool" }, "default": "false" }
586586
},
587587
"name": "DataGridPro",

docs/pages/x/api/data-grid/data-grid.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@
450450
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
451451
"default": "\"margin\""
452452
},
453+
"rowSpanning": { "type": { "name": "bool" }, "default": "false" },
453454
"scrollbarSize": { "type": { "name": "number" } },
454455
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
455456
"showColumnVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
@@ -476,7 +477,6 @@
476477
},
477478
"additionalInfo": { "sx": true }
478479
},
479-
"unstable_rowSpanning": { "type": { "name": "bool" }, "default": "false" },
480480
"virtualizeColumnsWithAutoRowHeight": { "type": { "name": "bool" }, "default": "false" }
481481
},
482482
"name": "DataGrid",

docs/translations/api-docs/data-grid/data-grid-premium/data-grid-premium.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@
621621
"rowSpacingType": {
622622
"description": "Sets the type of space between rows added by <code>getRowSpacing</code>."
623623
},
624+
"rowSpanning": {
625+
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
626+
},
624627
"scrollbarSize": {
625628
"description": "Override the height/width of the Data Grid inner scrollbar."
626629
},
@@ -667,9 +670,6 @@
667670
"unstable_listView": {
668671
"description": "If <code>true</code>, displays the data in a list view. Use in combination with <code>unstable_listColumn</code>."
669672
},
670-
"unstable_rowSpanning": {
671-
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
672-
},
673673
"virtualizeColumnsWithAutoRowHeight": {
674674
"description": "If <code>true</code>, the Data Grid enables column virtualization when <code>getRowHeight</code> is set to <code>() =&gt; &#39;auto&#39;</code>. By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly. For datasets with a large number of columns, this can cause performance issues. The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally."
675675
}

docs/translations/api-docs/data-grid/data-grid-pro/data-grid-pro.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@
563563
"rowSpacingType": {
564564
"description": "Sets the type of space between rows added by <code>getRowSpacing</code>."
565565
},
566+
"rowSpanning": {
567+
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
568+
},
566569
"scrollbarSize": {
567570
"description": "Override the height/width of the Data Grid inner scrollbar."
568571
},
@@ -605,9 +608,6 @@
605608
"unstable_listView": {
606609
"description": "If <code>true</code>, displays the data in a list view. Use in combination with <code>unstable_listColumn</code>."
607610
},
608-
"unstable_rowSpanning": {
609-
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
610-
},
611611
"virtualizeColumnsWithAutoRowHeight": {
612612
"description": "If <code>true</code>, the Data Grid enables column virtualization when <code>getRowHeight</code> is set to <code>() =&gt; &#39;auto&#39;</code>. By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly. For datasets with a large number of columns, this can cause performance issues. The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally."
613613
}

docs/translations/api-docs/data-grid/data-grid/data-grid.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@
458458
"rowSpacingType": {
459459
"description": "Sets the type of space between rows added by <code>getRowSpacing</code>."
460460
},
461+
"rowSpanning": {
462+
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
463+
},
461464
"scrollbarSize": {
462465
"description": "Override the height/width of the Data Grid inner scrollbar."
463466
},
@@ -479,9 +482,6 @@
479482
"sx": {
480483
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
481484
},
482-
"unstable_rowSpanning": {
483-
"description": "If <code>true</code>, the Data Grid will auto span the cells over the rows having the same value."
484-
},
485485
"virtualizeColumnsWithAutoRowHeight": {
486486
"description": "If <code>true</code>, the Data Grid enables column virtualization when <code>getRowHeight</code> is set to <code>() =&gt; &#39;auto&#39;</code>. By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly. For datasets with a large number of columns, this can cause performance issues. The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally."
487487
}

packages/x-data-grid-premium/src/DataGridPremium/DataGridPremium.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ DataGridPremiumRaw.propTypes = {
10041004
* @default "margin"
10051005
*/
10061006
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
1007+
/**
1008+
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
1009+
* @default false
1010+
*/
1011+
rowSpanning: PropTypes.bool,
10071012
/**
10081013
* Override the height/width of the Data Grid inner scrollbar.
10091014
*/
@@ -1118,11 +1123,6 @@ DataGridPremiumRaw.propTypes = {
11181123
*/
11191124
unstable_listView: PropTypes.bool,
11201125
unstable_onDataSourceError: PropTypes.func,
1121-
/**
1122-
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
1123-
* @default false
1124-
*/
1125-
unstable_rowSpanning: PropTypes.bool,
11261126
/**
11271127
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
11281128
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.

packages/x-data-grid-premium/src/tests/rowSpanning.DataGridPremium.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('<DataGridPremium /> - Row spanning', () => {
99
const { render } = createRenderer();
1010

1111
const baselineProps: DataGridPremiumProps = {
12-
unstable_rowSpanning: true,
12+
rowSpanning: true,
1313
columns: [
1414
{
1515
field: 'code',

packages/x-data-grid-pro/src/DataGridPro/DataGridPro.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,11 @@ DataGridProRaw.propTypes = {
911911
* @default "margin"
912912
*/
913913
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
914+
/**
915+
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
916+
* @default false
917+
*/
918+
rowSpanning: PropTypes.bool,
914919
/**
915920
* Override the height/width of the Data Grid inner scrollbar.
916921
*/
@@ -1018,11 +1023,6 @@ DataGridProRaw.propTypes = {
10181023
*/
10191024
unstable_listView: PropTypes.bool,
10201025
unstable_onDataSourceError: PropTypes.func,
1021-
/**
1022-
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
1023-
* @default false
1024-
*/
1025-
unstable_rowSpanning: PropTypes.bool,
10261026
/**
10271027
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
10281028
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.

packages/x-data-grid/src/DataGrid/DataGrid.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ DataGridRaw.propTypes = {
749749
* @default "margin"
750750
*/
751751
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
752+
/**
753+
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
754+
* @default false
755+
*/
756+
rowSpanning: PropTypes.bool,
752757
/**
753758
* Override the height/width of the Data Grid inner scrollbar.
754759
*/
@@ -800,11 +805,6 @@ DataGridRaw.propTypes = {
800805
PropTypes.func,
801806
PropTypes.object,
802807
]),
803-
/**
804-
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
805-
* @default false
806-
*/
807-
unstable_rowSpanning: PropTypes.bool,
808808
/**
809809
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
810810
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.

packages/x-data-grid/src/constants/dataGridPropsDefaultValues.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES: DataGridPropsWithDefaultValues = {
5050
rows: [],
5151
rowSelection: true,
5252
rowSpacingType: 'margin',
53+
rowSpanning: false,
5354
showCellVerticalBorder: false,
5455
showColumnVerticalBorder: false,
5556
sortingMode: 'client',
5657
sortingOrder: ['asc' as const, 'desc' as const, null],
5758
throttleRowsMs: 0,
58-
unstable_rowSpanning: false,
5959
virtualizeColumnsWithAutoRowHeight: false,
6060
};

packages/x-data-grid/src/hooks/features/rows/useGridRowSpanning.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const computeRowSpanningState = (
164164
* @requires filterStateInitializer (method) - should be initialized before
165165
*/
166166
export const rowSpanningStateInitializer: GridStateInitializer = (state, props, apiRef) => {
167-
if (props.unstable_rowSpanning) {
167+
if (props.rowSpanning) {
168168
const rowIds = state.rows!.dataRowIds || [];
169169
const orderedFields = state.columns!.orderedFields || [];
170170
const dataRowIdToModelLookup = state.rows!.dataRowIdToModelLookup;
@@ -221,7 +221,7 @@ export const rowSpanningStateInitializer: GridStateInitializer = (state, props,
221221

222222
export const useGridRowSpanning = (
223223
apiRef: React.MutableRefObject<GridPrivateApiCommunity>,
224-
props: Pick<DataGridProcessedProps, 'unstable_rowSpanning' | 'pagination' | 'paginationMode'>,
224+
props: Pick<DataGridProcessedProps, 'rowSpanning' | 'pagination' | 'paginationMode'>,
225225
): void => {
226226
const { range, rows: visibleRows } = useGridVisibleRows(apiRef, props);
227227
const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
@@ -247,7 +247,7 @@ export const useGridRowSpanning = (
247247
// - The `paginationModel` is updated
248248
// - The rows are updated
249249
(resetState: boolean = true) => {
250-
if (!props.unstable_rowSpanning) {
250+
if (!props.rowSpanning) {
251251
if (apiRef.current.state.rowSpanning !== EMPTY_STATE) {
252252
apiRef.current.setState((state) => ({ ...state, rowSpanning: EMPTY_STATE }));
253253
}
@@ -320,15 +320,7 @@ export const useGridRowSpanning = (
320320
};
321321
});
322322
},
323-
[
324-
apiRef,
325-
props.unstable_rowSpanning,
326-
range,
327-
renderContext,
328-
visibleRows,
329-
colDefs,
330-
processedRange,
331-
],
323+
[apiRef, props.rowSpanning, range, renderContext, visibleRows, colDefs, processedRange],
332324
);
333325

334326
const prevRenderContext = React.useRef(renderContext);

packages/x-data-grid/src/models/props/DataGridProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export interface DataGridPropsWithDefaultValues<R extends GridValidRowModel = an
379379
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
380380
* @default false
381381
*/
382-
unstable_rowSpanning: boolean;
382+
rowSpanning: boolean;
383383
/**
384384
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
385385
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.

0 commit comments

Comments
 (0)