I'm using Material UI's Datagrid with cell editing. Everything is working great except that when I persist a value there is a chance that it eror's and if this is the case then I need to revert back to the initial state.
I thought I could simply refetch my data from the API and the changes would be straight away shown to the user. However in the case of an error my API data doesn't change: so the Material UI's internal Datagrid state does not trigger a refresh and uses the persisted local value.
This is my datagrid:
<DataGrid
rows={data}
columns={columns}
onEditCellChangeCommitted={(values, event) => {
updateApi(values).then(r => {
//Success
}).catch(e => {
//Error Whilst updating
// Revert back to passed in Data
}
).finally(() => {
//api.forceUpdate(null);
}
)
}}
/>
I tried to do do a api.forceUpdate(null); but that didn't work. I also tried to set the editMode to server, which again didn't work.
I also tried event.stopPropogation() but as I don't know if I want to stop the process until the updateApi promise is resolved the change is already committed.