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

How to trigger preProcessEditCellProps on click of save #15010

Open
achoud444 opened this issue Oct 17, 2024 · 3 comments
Open

How to trigger preProcessEditCellProps on click of save #15010

achoud444 opened this issue Oct 17, 2024 · 3 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: question Community support but can be turned into an improvement

Comments

@achoud444
Copy link

achoud444 commented Oct 17, 2024

Summary

I am trying to make edit and save in mui datagrid cell. Here is the link .

Several thing are not working here. Please help with this.

  1. Country is not changing.
  2. On change of country I also want to change the vat based on country.
  3. If the country is not selected then clicking on save it should throw error on the cell which its background as red.

Examples

No response

Motivation

No response

Search keywords: How to trigger preProcessEditCellProps on click of save

@achoud444 achoud444 added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 17, 2024
@achoud444
Copy link
Author

@MBilalShafi @michelengelen Can you please help here

@MBilalShafi MBilalShafi added the component: data grid This is the name of the generic UI component, not the React module! label Oct 17, 2024
@MBilalShafi
Copy link
Member

MBilalShafi commented Oct 18, 2024

Country is not changing

You could use singleSelect column type instead of adding a renderEditCell for this purpose, it's built for the same purpose. Here's a list of all available column types: https://mui.com/x/react-data-grid/column-definition/#column-types

If you also want to show the tooltip for the error, you might duplicate the GridEditSingleSelect component, add your functionality, and pass it as renderEditCell for the country column.

On change of country I also want to change the vat based on country.

Using processRowUpdate could help achieve that.

If the country is not selected then clicking on save it should throw error on the cell which its background as red.

The colDef.preProcessEditCellProps should do this. See answer to first point for adding the tooltip.

I tried to update your example to support these usecases (without the Tooltip part), here's the updated example: https://stackblitz.com/edit/react-ct2cgh?file=Demo.tsx

Is this what you are intending to do?

@MBilalShafi MBilalShafi added status: waiting for author Issue with insufficient information support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer new feature New feature or request labels Oct 18, 2024
@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Oct 21, 2024
@achoud444
Copy link
Author

@MBilalShafi Thanks for the reply

If the country is not selected then clicking on save it should throw error on the cell which its background as red.

This is still not working.. Suppose I add a new row if you can see here. On click of save I want to highlight the cells with red border (name and country). Can I do that?

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! status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants