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] processRowUpdate - pass the modified row index in the arguments #16128

Closed
TeoAvignon opened this issue Jan 10, 2025 · 5 comments
Closed
Labels
component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature new feature New feature or request performance

Comments

@TeoAvignon
Copy link

TeoAvignon commented Jan 10, 2025

Summary

Currently, the function arguments are oldRow, newRow, params which only has rowId inside.

If your data is an array, it means updating it will be O(n) while it could be O(1) with the row index.

Could you please also give the row index. Thus, people could choose between the index and the id to update their data based on their current implementation (array or dictionnary)

Examples

image

Motivation

I would like to improve the performance of my app

Search keywords: processRowUpdate, index

Order ID: #42756

@TeoAvignon TeoAvignon added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 10, 2025
@michelengelen michelengelen changed the title [processRowUpdate] - pass the modified row index in the arguments [data grid] processRowUpdate - pass the modified row index in the arguments Jan 13, 2025
@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature performance and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 13, 2025
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jan 13, 2025
@michelengelen
Copy link
Member

Hey @TeoAvignon I don't think we can support this, as we only store the relative index and not the index it has on the original array ... i might be mistaken though.

I know that @romgrk is advocating to use Map instead of Array as a form of passing the rows to increase DX and performance, but I am not sure how far he has gotten with this yet.

what we can provide is the relative index using apiRef: apiRef.current?.getRowIndexRelativeToVisibleRows(params.rowId)

@MBilalShafi do you have any additional information on this?

@TeoAvignon
Copy link
Author

Thanks for your quick response @michaelNXT1 !

For the apiRef, I think it is equivalent to a find isn't it ?

@romgrk
Copy link
Contributor

romgrk commented Jan 14, 2025

I don't think that we maintain an id->index lookup for this case. We maintain one for rows after sorting, because we need that ordering for rendering purposes, but we don't maintain one for the original dataset as it doesn't make sense for us to do it for everyone just to provide that parameter. I suggest that you create an id->index Map on your side.

@TeoAvignon
Copy link
Author

Seems ok to me ! Thanks for responding so quickly. I'll use this solution.

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.

Note

@TeoAvignon 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.

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! enhancement This is not a bug, nor a new feature new feature New feature or request performance
Projects
None yet
Development

No branches or pull requests

3 participants