javascriptag-gridag-grid-reactag-grid-validation

In Ag-grid-react how to disable update button if edited cell is not valid?


I'm trying to disable update button after validating cell editor enter image description here

link for full code, https://stackblitz.com/edit/react-hooks-complex-editor-3b7ybk?file=src%2FApp.js,src%2FComponents%2FEditors%2FSimpleEditor.jsx,src%2FComponents%2FEditors%2FAsyncValidationEditor.jsx,src%2Folympic_lists.js,src%2Fcolumns.js,src%2Futils.js,src%2FApp.css


Solution

  • In the renderer - ActionsRenderer

    Below are the changes I made.

    export default forwardRef((props, ref) => {
    ...
      let [updateDisabled, setUpdateDisabled] = useState(false);
    ...
      useImperativeHandle(ref, () => ({
        exposedUpdateDisabled: setUpdateDisabled,
      }));
    })
    

    In the validator - AsyncValidationEditor(or whatever editor you plan to use)

    here is your updated code : https://stackblitz.com/edit/react-hooks-complex-editor-5xr8na?file=src%2FApp.js,src%2FComponents%2FEditors%2FSimpleEditor.jsx,src%2FComponents%2FEditors%2FAsyncValidationEditor.jsx,src%2Folympic_lists.js,src%2Fcolumns.js,src%2Futils.js,src%2FComponents%2FRenderers%2FActionsRenderer.jsx