Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Make data source stable #16710

Merged
merged 10 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data/data-grid/prompt/PromptWithDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function PromptWithDataSource() {
<div style={{ height: 500, width: '100%' }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/prompt/PromptWithDataSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function PromptWithDataSource() {
<div style={{ height: 500, width: '100%' }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
6 changes: 3 additions & 3 deletions docs/data/data-grid/row-grouping/row-grouping.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ If you want to expand the whole tree, set `defaultGroupingExpansionDepth = -1`

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

If you want to expand groups by default according to a more complex logic, use the `isGroupExpandedByDefault` prop which is a callback receiving the node as an argument.
If you want to expand groups by default according to a more complex logic, use the `isGroupExpandedByDefault()` prop which is a callback receiving the node as an argument.
When defined, this callback will always have priority over the `defaultGroupingExpansionDepth` prop.

```tsx
Expand All @@ -252,12 +252,12 @@ isGroupExpandedByDefault={

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

Use the `setRowChildrenExpansion` method on `apiRef` to programmatically set the expansion of a row. Changing the expansion of a row emits a `rowExpansionChange` event, listen to it to react to the expansion change.
Use the `setRowChildrenExpansion()` method on `apiRef` to programmatically set the expansion of a row. Changing the expansion of a row emits a `rowExpansionChange` event, listen to it to react to the expansion change.

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

:::warning
The `apiRef.current.setRowChildrenExpansion` method is not compatible with the [server-side tree data](/x/react-data-grid/server-side-data/tree-data/) and [server-side row grouping](/x/react-data-grid/server-side-data/row-grouping/). Use `apiRef.current.unstable_dataSource.fetchRows` instead.
The `apiRef.current.setRowChildrenExpansion()` method is not compatible with the [server-side tree data](/x/react-data-grid/server-side-data/tree-data/) and [server-side row grouping](/x/react-data-grid/server-side-data/row-grouping/). Use `apiRef.current.dataSource.fetchRows()` instead.
:::

### Customize grouping cell indent
Expand Down
8 changes: 8 additions & 0 deletions docs/data/data-grid/row-updates/row-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Multiple row updates at a time are supported in [Pro](/x/introduction/licensing/

## Infinite loading [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')

:::warning
This feature is deprecated, use the [Server-side data—Infinite loading](/x/react-data-grid/server-side-data/lazy-loading/#infinite-loading) instead.
:::

The grid provides a `onRowsScrollEnd` prop that can be used to load additional rows when the scroll reaches the bottom of the viewport area.

In addition, the area in which `onRowsScrollEnd` is called can be changed using `scrollEndThreshold`.
Expand All @@ -52,6 +56,10 @@ Otherwise, the sorting and filtering will only be applied to the subset of rows

## Lazy loading [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')

:::warning
This feature is deprecated, use the [Server-side data—Viewport loading](/x/react-data-grid/server-side-data/lazy-loading/#viewport-loading) instead.
:::

Lazy Loading works like a pagination system, but instead of loading new rows based on pages, it loads them based on the viewport.
It loads new rows in chunks, as the user scrolls through the Data Grid and reveals empty rows.

Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/server-side-data/ServerSideDataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ServerSideDataGrid() {
<div style={{ width: '100%', height: 400 }}>
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={{
...initialState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ServerSideDataGrid() {
<div style={{ width: '100%', height: 400 }}>
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={{
...initialState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={{
...initialState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function ServerSideDataGridAggregation() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function ServerSideDataGridAggregation() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default function ServerSideDataGridAggregationLazyLoading() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={{
...initialState,
pagination: { paginationModel: { pageSize: 10, page: 0 }, rowCount: 0 },
aggregation: {
model: { commodity: 'size', quantity: 'sum' },
},
}}
unstable_lazyLoading
lazyLoading
aggregationFunctions={aggregationFunctions}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export default function ServerSideDataGridAggregationLazyLoading() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={{
...initialState,
pagination: { paginationModel: { pageSize: 10, page: 0 }, rowCount: 0 },
aggregation: {
model: { commodity: 'size', quantity: 'sum' },
},
}}
unstable_lazyLoading
lazyLoading
aggregationFunctions={aggregationFunctions}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={{
...initialState,
pagination: { paginationModel: { pageSize: 10, page: 0 }, rowCount: 0 },
aggregation: {
model: { commodity: 'size', quantity: 'sum' },
},
}}
unstable_lazyLoading
lazyLoading
aggregationFunctions={aggregationFunctions}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function ServerSideDataGridAggregationRowGrouping() {
<DataGridPremium
apiRef={apiRef}
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={initialStateUpdated}
aggregationFunctions={aggregationFunctions}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function ServerSideDataGridAggregationRowGrouping() {
<DataGridPremium
apiRef={apiRef}
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={initialStateUpdated}
aggregationFunctions={aggregationFunctions}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPremium
apiRef={apiRef}
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
initialState={initialStateUpdated}
aggregationFunctions={aggregationFunctions}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function ServerSideDataGridAggregationTreeData() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
treeData
apiRef={apiRef}
initialState={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function ServerSideDataGridAggregationTreeData() {
<div style={{ width: '100%', height: 400 }}>
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
treeData
apiRef={apiRef}
initialState={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DataGridPremium
columns={columns}
unstable_dataSource={dataSource}
dataSource={dataSource}
treeData
apiRef={apiRef}
initialState={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default function ServerSideDataGridNoCache() {
<DataGrid
initialState={initialStateWithPagination}
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={null}
dataSource={dataSource}
dataSourceCache={null}
pagination
pageSizeOptions={pageSizeOptions}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default function ServerSideDataGridNoCache() {
<DataGrid
initialState={initialStateWithPagination}
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={null}
dataSource={dataSource}
dataSourceCache={null}
pagination
pageSizeOptions={pageSizeOptions}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<DataGrid
initialState={initialStateWithPagination}
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={null}
dataSource={dataSource}
dataSourceCache={null}
pagination
pageSizeOptions={pageSizeOptions}
/>
4 changes: 2 additions & 2 deletions docs/data/data-grid/server-side-data/ServerSideDataGridTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default function ServerSideDataGridTTL() {
<div style={{ width: '100%', height: 400 }}>
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={lowTTLCache}
dataSource={dataSource}
dataSourceCache={lowTTLCache}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default function ServerSideDataGridTTL() {
<div style={{ width: '100%', height: 400 }}>
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={lowTTLCache}
dataSource={dataSource}
dataSourceCache={lowTTLCache}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGrid
columns={columns}
unstable_dataSource={dataSource}
unstable_dataSourceCache={lowTTLCache}
dataSource={dataSource}
dataSourceCache={lowTTLCache}
pagination
initialState={initialStateWithPagination}
pageSizeOptions={[10, 20, 50]}
Expand Down
10 changes: 4 additions & 6 deletions docs/data/data-grid/server-side-data/ServerSideErrorHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function ServerSideErrorHandling() {
<Button
onClick={() => {
setError('');
apiRef.current?.unstable_dataSource.fetchRows();
apiRef.current?.dataSource.fetchRows();
}}
>
Refetch rows
Expand All @@ -103,11 +103,9 @@ export default function ServerSideErrorHandling() {
<div style={{ height: 400, position: 'relative' }}>
<DataGrid
{...props}
unstable_dataSource={dataSource}
unstable_onDataSourceError={(dataSourceError) =>
setError(dataSourceError.message)
}
unstable_dataSourceCache={null}
dataSource={dataSource}
onDataSourceError={(dataSourceError) => setError(dataSourceError.message)}
dataSourceCache={null}
apiRef={apiRef}
pagination
pageSizeOptions={pageSizeOptions}
Expand Down
10 changes: 4 additions & 6 deletions docs/data/data-grid/server-side-data/ServerSideErrorHandling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function ServerSideErrorHandling() {
<Button
onClick={() => {
setError('');
apiRef.current?.unstable_dataSource.fetchRows();
apiRef.current?.dataSource.fetchRows();
}}
>
Refetch rows
Expand All @@ -108,11 +108,9 @@ export default function ServerSideErrorHandling() {
<div style={{ height: 400, position: 'relative' }}>
<DataGrid
{...props}
unstable_dataSource={dataSource}
unstable_onDataSourceError={(dataSourceError) =>
setError(dataSourceError.message)
}
unstable_dataSourceCache={null}
dataSource={dataSource}
onDataSourceError={(dataSourceError) => setError(dataSourceError.message)}
dataSourceCache={null}
apiRef={apiRef}
pagination
pageSizeOptions={pageSizeOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,22 @@ function ServerSideLazyLoadingErrorHandling() {
<ErrorSnackbar
open={!!retryParams}
onRetry={() => {
apiRef.current?.unstable_dataSource.fetchRows(
GRID_ROOT_GROUP_ID,
retryParams,
);
apiRef.current?.dataSource.fetchRows(GRID_ROOT_GROUP_ID, retryParams);
setRetryParams(null);
}}
/>
)}
<DataGridPro
{...props}
apiRef={apiRef}
unstable_dataSource={dataSource}
unstable_onDataSourceError={(error) => {
dataSource={dataSource}
onDataSourceError={(error) => {
if (error instanceof GridGetRowsError) {
setRetryParams(error.params);
}
}}
unstable_dataSourceCache={null}
unstable_lazyLoading
dataSourceCache={null}
lazyLoading
paginationModel={{ page: 0, pageSize: 10 }}
showToolbar
/>
Expand Down
Loading
Loading