-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Pass rowId
param to processRowUpdate
#14821
Conversation
Deploy preview: https://deploy-preview-14821--material-ui-x.netlify.app/ Updated pages: |
* @returns {Promise<R> | R} The final values to update the row. | ||
*/ | ||
processRowUpdate?: (newRow: R, oldRow: R) => Promise<R> | R; | ||
processRowUpdate?: (newRow: R, oldRow: R, rowId?: GridRowId) => Promise<R> | R; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why optional though? It seems that we can guarantee rowId
presence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I update api in docs, I am running pnpm docs:api
but it is not updating files ?
* @returns {Promise<R> | R} The final values to update the row. | ||
*/ | ||
processRowUpdate?: (newRow: R, oldRow: R) => Promise<R> | R; | ||
processRowUpdate?: (newRow: R, oldRow: R, rowId: GridRowId) => Promise<R> | R; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of having 3 flat params with no apparent hierarchy.
If the method is not super frequently called, maybe putting the id in a additionalParams
object would make sure that we stick with 3 params even if we have more info to pass to this function in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the suggestion
the method is called on stop editing and copy paste, I think we should implement this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Resolves #13381
This PR adds a third parameter
rowId
toprocessRowUpdate
method. However, one can useapiRef.current.getRowId
to retrieve the id of the row. Still, the more reliable and efficient approach is to pass row id as a parameter as @cherniavskii mentioned here.By doing so, one can opt out of adding
apiRef
to the dependency array inuseCallback
, which may improve performance if the method is expensive.