mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.11k stars 1.27k forks source link

Row Edit. On singleSelect column value change, set other's column value. #9031

Open AnastasiaEvgenia opened 1 year ago

AnastasiaEvgenia commented 1 year ago

Order ID or Support key 💳 (optional)

56556

Duplicates

Latest version

The problem in depth 🔍

Hi.

When editing a grid row, I would like to set a specific value on a text column 'i.e. email column', when I select an option to another singleSelect column 'i.e contacts'.

The logic behind this is that, when I select a contact from singleSelect list, I find the contact's email from an array of contacts and then I set the email to the value of email grid column.

I 've tried with the valueSetter and valueGetter or with a similar implementation to documentation example 'Linked fields https://mui.com/x/react-data-grid/recipes-editing/#linked-fields', but it doesn't work.

Can you please help me? I have added in a zip the AddContact.js file that uses the Grid and the editable grid component that Uses DataGridPro.

Thank you. editable grid.zip

Your environment 🌎

`npx @mui/envinfo` ``` System: OS: Windows 10 10.0.19045 Binaries: Node: 20.1.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 9.6.6 - C:\inetpub\wwwroot\Orion\node_modules\.bin\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.42) npmPackages: @emotion/react: ^11.9.3 => 11.11.0 @emotion/styled: ^11.9.3 => 11.11.0 @mui/base: ^5.0.0-alpha.120 => 5.0.0-alpha.128 @mui/core-downloads-tracker: 5.12.3 @mui/icons-material: ^5.11.11 => 5.11.16 @mui/lab: ^5.0.0-alpha.122 => 5.0.0-alpha.129 @mui/material: ^5.11.12 => 5.12.3 @mui/private-theming: 5.12.3 @mui/styled-engine: 5.12.3 @mui/system: 5.12.3 @mui/types: 7.2.4 @mui/utils: 5.12.3 @mui/x-data-grid: 6.3.1 @mui/x-data-grid-generator: ^6.0.1 => 6.3.1 @mui/x-data-grid-premium: 6.3.1 @mui/x-data-grid-pro: ^6.0.0 => 6.3.1 @mui/x-date-pickers: ^6.0.0 => 6.3.1 @mui/x-date-pickers-pro: ^6.0.0 => 6.3.1 @mui/x-license-pro: ^6.0.0 => 6.0.4 @types/react: 17.0.59 react: ^17.0.1 => 17.0.2 react-dom: ^17.0.1 => 17.0.2 ```
m4theushw commented 1 year ago

The example in https://mui.com/x/react-data-grid/recipes-editing/#linked-fields works by creating a custom edit component and setting the value of the other column in onValueChange, however, the demo provided doesn't have any custom component.