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

[DataGrid] Pass rowId param to processRowUpdate #14821

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

k-rajat19
Copy link
Contributor

@k-rajat19 k-rajat19 commented Oct 4, 2024

Resolves #13381

This PR adds a third parameter rowId to processRowUpdate method. However, one can use apiRef.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 in useCallback, which may improve performance if the method is expensive.

@mui-bot
Copy link

mui-bot commented Oct 4, 2024

Deploy preview: https://deploy-preview-14821--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against fe75613

* @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;
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can 👍

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Oct 4, 2024
@cherniavskii cherniavskii added feature: Editing Related to the data grid Editing feature enhancement This is not a bug, nor a new feature dx Related to developers' experience labels Oct 7, 2024
Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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 enhancement This is not a bug, nor a new feature feature: Editing Related to the data grid Editing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] processRowUpdate should give access to the id of the row when getRowId() is used
5 participants