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

x-datagrid with Next.js and dynamic data does not display data on pages >= 2 #5048

Closed
2 tasks done
samfweb opened this issue May 30, 2022 · 3 comments
Closed
2 tasks done
Labels
component: data grid This is the name of the generic UI component, not the React module!

Comments

@samfweb
Copy link

samfweb commented May 30, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

x-grid (and pro) only shows the last row on pages after the first when the rows prop changes on page change (such as with serverside pagination enabled).

image

This only occurs with Next.JS. I've tried to recreate this example with vanilla react and can't.

Edit: I've also found some rows flicker and swap... unsure if this is also relevant?

row flicker example

Expected behavior 🤔

The grid should show all rows on all pages.

Steps to reproduce 🕹

Code sandbox here: https://codesandbox.io/s/nextjs-mui-datagrid-not-displaying-rows-zznwxc?file=/pages/index.tsx

Steps:

  1. Click next page
  2. See that only 1 row is displayed despite rows having 5 entries
  3. Click next page to see this behavior happens on all subsequent pages

Context 🔦

I need to use serverside pagination on our application as datasets sent to the client are becoming too large.

This bug is preventing me from releasing the next update.

Your environment 🌎

`npx @mui/envinfo`
  System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.53)
  npmPackages:
    @emotion/react: ^11.9.0 => 11.9.0
    @emotion/styled: ^11.8.1 => 11.8.1
    @mui/icons-material: ^5.8.0 => 5.8.0
    @mui/lab: ^5.0.0-alpha.83 => 5.0.0-alpha.83
    @mui/material: ^5.8.1 => 5.8.1
    @mui/styles: ^5.8.0 => 5.8.0
    @mui/types:  7.1.3
    @mui/x-data-grid-pro: ^5.11.1 => 5.11.1
    @mui/x-date-pickers: ^5.0.0-alpha.4 => 5.0.0-alpha.4
    @types/react: 18.0.9 => 18.0.9
    react: 18.1.0 => 18.1.0
    react-dom: 18.1.0 => 18.1.0
    typescript: 4.7.2 => 4.7.2

Browsers used are Brave and Chrome

Order ID 💳 (optional)

30466

@samfweb samfweb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 30, 2022
@m4theushw
Copy link
Member

You seem to have missed setting paginationMode to "server". Without it, the grid will slice the rows received.

Updated CodeSandbox: https://codesandbox.io/s/nextjs-mui-datagrid-not-displaying-rows-forked-4lfb4b?file=/pages/index.tsx

Does it solve the problem ?

@m4theushw m4theushw added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 30, 2022
@samfweb
Copy link
Author

samfweb commented May 30, 2022

Yep, that does 😅 Totally missed that in the docs. Thank you.

Could I recommend a guide/separate page on creating a serverside implementation of x-grid?

I don't think it would be common behavior to partially implement serverside logic for eg. pagination but not filters, however currently the steps are fragmented across each individual page and the grid requires a bunch of different *mode="server" props.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label May 30, 2022
@m4theushw
Copy link
Member

Could I recommend a guide/separate page on creating a serverside implementation of x-grid?

Yes, we want to improve that part. You can follow #7583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

2 participants