-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[data grid] Trigger preProcessEditCellProps
from view by e.g onKeyDown / similar to e.g paste from clipboard (for date fields)
#15058
Comments
@atsoy please could you provide a minimal reproduction of the issue? |
Sorry for delayed response @KenanYusuf . Here is Demo Hope it helps |
preProcessEditCellProps
from view by e.g onKeyDown / similar to e.g paste from clipboard (for date fields)
Thanks for the reproduction @atsoy. Makes sense to me that backspace and pasting would trigger the validation logic on any field. You could potentially call const handleKeyDown = (params: GridCellParams, event: React.KeyboardEvent) => {
if (event.key === 'Backspace' && params.colDef.preProcessEditCellProps) {
params.colDef.preProcessEditCellProps({
// params
});
}
};
<DataGrid onCellKeyDown={handleKeyDown} /> @mui/xgrid should we have this behaviour by default? |
Thanks for the provided workaround idea, @KenanYusuf . I've extended the Demo. And it looks like the Validation is being triggered manually, but e.g Did I miss something? |
Totally agree. Validation should happen on value change regardless how it happened |
@atsoy it doesn't behave how I expected, sorry about that. I'm working on a fix but will let you know if I think of any other workarounds in the meantime |
For clipboard pasting, I didn't use the |
This seems like a good option. |
thank you @KenanYusuf ! |
hi @cherniavskii , might be just my expectation, but as an user I would expect edit mode, as soon as the displayed values was modified (by starting to type on keyboard, copy/paste, backspace etc). Corresponding it would also validate the input onChange. But as I've said, it might be just matter of perspective. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @atsoy How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The problem in depth
Description
We use
preProcessEditCellProps
for validating entries in cells (mostly ineditMode === "row"
).In some use cases we need to validate date fields (e.g if the value is after provided date or
null
is not allowed). It works also almost out of the box, by usingGridDataEditCell
with a customTooltip
, but only, if the values was set over built-in Date picker.Is there a way to trigger / start validation (aka
preProcessEditCellProps
) by e.g entering the edit mode? Some use cases:Backspace
(or starting to type date eg. "202310" to remove the value should trigger validationSnippet examples
P.S: I've also noticed that validation is being triggered, ONLY when the full date was entered (via keyboard or selected from the date picker). Is it possible to adjust this behaviour and run it e.g for not fully entered date (via keyboard)?
Look forward to hearing from you!
Your environment
`npx @mui/envinfo`
Search keywords: preProcessEditCellProps validation Date clipboard
Order ID: 62555
The text was updated successfully, but these errors were encountered: