Add onRowCancel function on editable tables
Is your feature request related to a problem? Please describe. I have a custom edit component that is a select dropdown with two options (A, and B)
My current idea is to have a state variable that is currentRowOption set to '' initially. In my editComponent, before returning the select component, I set the state variable to the value of the row, if and only if the state variable is equal to ''. I am able to to set the state variable back to '' in the onRowUpdate function, but I need to be able to reset it if the editing is cancelled.
Describe the solution you'd like
A function for onRowCancel
I found a way to do this using material tables props that gets passed into the onedit function.
I still think this would be useful
@jakeleventhal Can you post an example of how you got it to work please?
What i did was not use a state variable and instead use the supplied props on change function like this
<TextField
onChange={(e) => props.onChange(e.target.value)}
value={props.value}
/>
This works, but for something more detailed, the onRowCancel would be really helpful.
This is actually not needed. you can override editable.EditRow property that returns MTableEditRow and override onEditingApproved and onEditingCanceled. this applies to both add, update and delete.
onEditingCanceled
seems like onEditingCanceled is not recognized.Do you have an example?
components={{
EditRow: (props) => {
return (
<MTableEditRow
{...props}
onEditingApproved={(mode, newData, oldData) => {
}}
onEditingCanceled={(mode, rowData) => {
}}
/>
);
}}
}
components={{ EditRow: (props) => { return ( <MTableEditRow {...props} onEditingApproved={(mode, newData, oldData) => { }} onEditingCanceled={(mode, rowData) => { }} /> ); }} }
Hey I was able to use this but it wont allow me to select any dropdown value of any cell in my editComponent.I am doing something like this: components={{ EditRow: (props) => { return ( <MTableEditRow {...props} onEditingCanceled={(mode, rowData) => { setParents([]); setName(''); setId(''); props.onEditingCanceled(mode); }} /> ); }} }
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.