我目前有一个MUI X数据网格,我在其中验证了电子邮件字段。验证有效,并且确实会恢复为原始,但只有按下逃生键。为此,我修改了他们给出的

问题描述 投票:0回答:0

我认为我已经弄清楚了。我使用了格式化值,并将其放入IF语句中。这是更新的功能: function NameEditInputCell(props) { const { error, formattedValue } = props; const apiRef = useGridApiContext(); const handleBadEmail = async () => { if (error) { let oldValue = apiRef.current.setEditCellValue({ id: props.id, field: "email", value: formattedValue, }); apiRef.current.stopCellEditMode({ id: props.id, field: "email", value: oldValue, ignoreModifications: false, }); } }; return ( <StyledTooltip open={!!error} title={error}> <GridEditInputCell onBlur={handleBadEmail} {...props} /> </StyledTooltip> ); }

material-ui datagrid email-validation mui-x-data-grid
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.