material-uimui-x-data-grid

How can I fall back to the default behaviour when using MUI X Data Grid rendereditcell


I'm using MUI X Data Grid v5 (basic, not pro, etc.) and I need a custom renderEditCell function, which I know how to use, but the cell content can be either a plain string or an object. If its an object I want to use a custom editor but if its a plain string I want the user to be able to edit in-place as a normal cell.

So how can I return a value from my renderEditCell function that invokes the default behavour? Can I import the default function and return it?


Solution

  • You can use the GridEditInputCell component to fall back to the default.

    renderEditCell: (params) => {
        if (customCondition) {
           return (
               <CustomEditComponent />
           );
        }
        return <GridEditInputCell {...params} />;
     },