-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Using lazy loading with server side sorting raises an error #11417
Comments
Hey @jose-vilasboas-rlabs I am not able to reproduce the error. I tried for several minutes in multiple attempts. Let me loop in a member from the xGrid team if he has any idea how this could happen to you. @MBilalShafi do you know of any problems like this? |
I was able to reproduce it after a couple attempts, @michelengelen it doesn't show on the stackblitz console, I had to open the browser's console to see it. It seems like when updating sort multiple times, the grid variable on this line seems to become undefined which throws an error. I haven't confirmed but this could be a quick fix I guess: diff --git a/packages/grid/x-data-grid/src/hooks/features/rows/useGridRows.ts b/packages/grid
/x-data-grid/src/hooks/features/rows/useGridRows.ts
index 849560f83..9970d3606 100644
--- a/packages/grid/x-data-grid/src/hooks/features/rows/useGridRows.ts
+++ b/packages/grid/x-data-grid/src/hooks/features/rows/useGridRows.ts
@@ -440,7 +440,7 @@ export const useGridRows = (
tree[GRID_ROOT_GROUP_ID] = { ...rootGroup, children: rootGroupChildren };
// Removes potential remaining skeleton rows from the dataRowIds.
- const dataRowIds = rootGroupChildren.filter((childId) => tree[childId]?.type === 'leaf');
+ const dataRowIds = rootGroupChildren.filter((childId) => tree?.[childId]?.type === 'leaf');
apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup; @jose-vilasboas-rlabs If you want, feel free to open up a PR with the mentioned diff to access if it resolves the issue or someone from the team should be looking into it as some bandwidth is available. |
Interesting. Then the stackblitz console has a major flaw tbh.
Thanks for taking a look @MBilalShafi. I was looking around that part as well, but wasn't sure if it really is the culprit. |
Hi @michelengelen and @MBilalShafi. Thanks for your fast reply. Any news regarding the resolution of this issue? Thanks |
@jose-vilasboas-rlabs not as of now. We marked it as a 'good first issue' since the change is so small. We do this to give interested contributors a chance to pick it up. Do you want to pick it up maybe? If not I can do it as well. |
- when applying sort server side with a lazy loading DataGrid, and error an error was thrown because tree was undefined. - Validate if tree is defined before getting the childId property value
Hi again, I have created the pull request Hope eveything is ok with it. |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/react-xtoshv?file=Demo.tsx
I have picked your exact example for lazy loading and just enabled the sorting option for each column adding this line:
data.columns.forEach((item) => (item.sortable = true));
Steps:
1.Scroll up and down several times to load as much rows as possible
2.Change the sorting in any of the available columns
Note: You may have to load several records and perform sorting several times to achieve the issue
Current behavior
An error is printed in the console and the rows are not updated.
Expected behavior
No error printed and the the rows should be correctly updated.
Context
No response
Your environment
npx @mui/envinfo
Search keywords: lazy loading, sorting, useGridRows, unstable_replaceRows
Order ID: 79663
The text was updated successfully, but these errors were encountered: