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] Log error if rowCount is used with client-side pagination #12448

Merged
merged 10 commits into from
Apr 4, 2024
5 changes: 5 additions & 0 deletions docs/data/data-grid/pagination/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ React.useEffect(() => {
<DataGrid rowCount={rowCountState} />;
```

:::warning
The `rowCount` prop is used in server-side pagination mode to inform the DataGrid about the total number of rows in your dataset.
This prop is ignored when the `paginationMode` is set to `client`, meaning the pagination is handled on the client-side.
:::

{{"demo": "ServerPaginationGrid.js", "bg": "inline"}}

### Cursor implementation
Expand Down
6 changes: 6 additions & 0 deletions packages/x-data-grid/src/internals/utils/propValidation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isNumber } from '@mui/x-data-grid/utils/utils';
import { DataGridProcessedProps } from '../../models/props/DataGridProps';

export type PropValidator<TProps> = (props: TProps) => string | undefined;
Expand All @@ -13,6 +14,11 @@ export const propValidatorsDataGrid: PropValidator<DataGridProcessedProps>[] = [
'Please remove one of these two props.',
].join('\n')) ||
undefined,
(props) =>
(props.paginationMode === 'client' &&
isNumber(props.rowCount) &&
'MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. `rowCount` is only meant to be used with `paginationMode="server"`.') ||
undefined,
];

const warnedOnceMap = new Set();
Expand Down
Loading