[data grid] Add a warning if `paginationMode=client` but `rowCount > rows.length`
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/p/sandbox/blissful-darkness-g67tq4?file=%2Fdemo.tsx%3A8%2C3
Steps: Click on the next page to see this phenomenon.Only one piece of data is displayed regardless of the number of pieces of data.
Current behavior 😯
After clicking the next page, only one piece of data is displayed except for the first page.
Expected behavior 🤔
Expect every page to display a normal amount of data.
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
System:
OS: Windows 10 10.0.22622
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\AthrunYoYo\project\eams\node_modules\.bin\yarn.CMD
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.22621.590.0)
npmPackages:
@emotion/react: ^11.10.5 => 11.10.5
@emotion/styled: ^11.10.5 => 11.10.5
@mui/base: 5.0.0-alpha.109
@mui/core-downloads-tracker: 5.10.17
@mui/material: ^5.10.15 => 5.10.17
@mui/private-theming: 5.10.16
@mui/styled-engine: 5.10.16
@mui/system: 5.10.17
@mui/types: 7.2.2
@mui/utils: 5.10.16
@mui/x-data-grid: ^5.17.14 => 5.17.14
@mui/x-date-pickers: ^5.0.10 => 5.0.10
@types/react: ^18.0.0 => 18.0.25
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^4.4.2 => 4.9.3
Order ID 💳 (optional)
No response
You forget paginationMode="server" to explicitly says that the pagination is handled by the server and not the data grid.
What I don't understand, is why you get one item instead of zeros
This one item in the 2nd page is the 5th item in rows. It's coming from https://github.com/mui/mui-x/blob/64bfb3195d4866353eb95daf3245f36a419c79e1/packages/grid/x-data-grid/src/hooks/features/pagination/gridPaginationSelector.ts#L55-L58
visibleTopLevelRowCount is always 5 and pagination.pageSize * pagination.page is 5 so 5 > 4 = 4
We could add a warning if paginationMode=client but rowCount > rows.length.
Reopening just to track the progresses on adding a warning
I think the rowCount prop should be ignored when paginationMode='client' as it doesn't seem to solve any legitimate use-cases, rather it's a kind of bug (if you observe the linked codesandbox, incrementing rowCount doesn't make a difference, it makes to show the incorrect rowCount which gets reset on page change anyways).
Instead visibleTopLevelRowCount should be used when paginationMode='client'. I've done that in https://github.com/mui/mui-x/pull/12381/files#diff-9a0e68c704ca6f0429e6db360d5133bc084fa1dbe9dc4323da03fe001a929bebR123-R129. We could add a warning like:
`rowCount` prop is ignored when `paginationMode = client`, consider setting `paginationMode = server` if you are doing pagination on server.
CC @mui/xgrid