-
-
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
Customizing Functionality and Appearance of Editable DataGrid Cell #8854
Comments
|
This outline only appears when the cell is in edit mode. Basically you need to put all cells from a column in edit mode and this is not supported easily. Entering the edit mode of a cell requires an user interaction (double-click or single-click), but when this step is removed there's a problem when the cell is saved because the default behavior is to return to view mode, however, in this situation we want to stay on edit mode. If it's acceptable I would show an icon on the cells that are editable. You can do this providing a custom edit component. Example:
Did you check the initial value in the
This is not possible. I explained the reason above. About using the CSS classes, we have some demos in https://mui.com/x/react-data-grid/style/ that may help. |
OK, thanks for that response! Showing an Edit icon on the cells that are editable it is! *** NOTE preProcessEditCellProps was deleted as it was preventing the cell from exiting edit mode for invalid values
// custom input
}; and the latest addition, for the edit icon, EditableTextFieldCell: |
Order ID or Support key 💳 (optional)
331993142
Duplicates
Latest version
The problem in depth 🔍
I have a table defined with an editable column of type number.
This is a TWO PART QUESTION:
I would like to define min and max values for the number and have it display in error (red) if values are entered outside of the range, so that it would work similar to a text field input (the way TextField uses inputProps and error props). I found the following online: https://stackoverflow.com/questions/74513146/define-min-and-max-input-values-on-mui-datagrid-number-column-cell and added it to my column definition, and the range checking is working... but adding an error prop did not work and I was unable to find any API documentation for GridEditInputCell. I posted question [question] How to Customize Functionality and Appearance of Editable DataGrid Cell? #8769 and was told to use preProcessEditCellProps. I have added the use of preProcessEditCellProps for the validation and error prop as follows:
preProcessEditCellProps: (params) => {
const hasError = params.props.value < 0 || params.props.value > params.row.licensesAvailable;
const inputProps = { max: params.row.licensesAvailable, min: 0 };
return { ...params.props, error: hasError, inputProps };
}
However, this did not resolve the issue because setting error true does not render the input in red (range restriction still works this way tho). Also, it just seems to stay 'stuck' in edit mode and the value remains unchanged.
I would like to change the appearance of the editable column to make the editable cells obvious to the user without them having to double-click to see the input. is that possible? and if yes, how?
PLEASE DO NOT CLOSE until there have been responses to both parts of the question.
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: