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

[data grid] Lazy loading details when using Master detail feature #13437

Closed
joserodolfofreitas opened this issue Jun 10, 2024 · 4 comments · Fixed by #13453
Closed

[data grid] Lazy loading details when using Master detail feature #13437

joserodolfofreitas opened this issue Jun 10, 2024 · 4 comments · Fixed by #13453
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! dx Related to developers' experience feature: Master-detail Related to the data grid Master-detail feature feature: Server integration Better integration with backends, e.g. data source performance plan: Pro Impact at least one Pro user

Comments

@joserodolfofreitas
Copy link
Member

joserodolfofreitas commented Jun 10, 2024

Summary

If users don't have the data for the details locally, fetching details for each row happens when DataGrid is loaded without users querying for the details.

Motivation

If users don't have the data for the details locally, fetching details should happen on demand for performance reasons.

Live reproduction case

https://stackblitz.com/edit/react-zru5se-ssomts?file=Demo.tsx,package.json

Search keywords: lazy loading master detail

@joserodolfofreitas joserodolfofreitas added component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user feature: Master-detail Related to the data grid Master-detail feature labels Jun 10, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jun 10, 2024
@joserodolfofreitas joserodolfofreitas added performance dx Related to developers' experience feature: Server integration Better integration with backends, e.g. data source labels Jun 10, 2024
@cherniavskii cherniavskii self-assigned this Jun 11, 2024
@cherniavskii
Copy link
Member

A few comments on this demo:

  • Did you consider loading the data in the detail panel content component itself?
  • The getDetailPanelContent prop should not define the component inline, because for React this means that a different component is rendered every time, so it will unmount/mount it instead of just updating it. Here's a simple working example where you can see the DetailPanelContent component that is defined once, and then being used in the getDetailPanelContent function. The data loading is done in DetailPanelContent (so only when it's mounted).

I've also forked your demo and applied the points above: https://stackblitz.com/edit/react-zru5se-fxsghf?file=Demo.tsx,package.json
You can see the MovieDetails component that handles the data fetching.

@joserodolfofreitas
Copy link
Member Author

Alright, that solves the issue. Perhaps we can make it into a recipe. Thanks, @cherniavskii!

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@joserodolfofreitas: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@cherniavskii
Copy link
Member

Perhaps we can make it into a recipe

Opened #13453

@cherniavskii cherniavskii moved this from 🆕 Needs refinement to ✅ Done in MUI X Data Grid Jul 30, 2024
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! dx Related to developers' experience feature: Master-detail Related to the data grid Master-detail feature feature: Server integration Better integration with backends, e.g. data source performance plan: Pro Impact at least one Pro user
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants