There is no function to get the state of [enableEditing] when conditionally set
sdancer75 opened this issue · 1 comments
sdancer75 commented
material-react-table version
1.15.1
react & react-dom versions
18.2.0
Describe the bug and the steps to reproduce it
When the enableEditing
is set conditionally set, there is no way to get the value inside other properties of the MRT ie muiTableBodyCellProps
enableEditing: (row) => row.original.name === 'test' ? true : false
Minimal, Reproducible Example - (Optional, but Recommended)
https://github.com/KevinVandy/material-react-table/tree/v2/apps/material-react-table-docs/examples
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms
- I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
sdancer75 commented
Temporary solution
// Table Columns
const columns = useMemo(
() => [
{
header: 'New',
accessorKey: 'new',
enableEditing: (row) => row.original.name === 'test' ? true : false
}
],
[]
);
..........
...............
// Inside Material React Table component you can use
..........
...............
muiTableBodyCellProps={({ row, cell }) => {
const _enableEditing = cell?.column?.columnDef?.enableEditing;
const enableEditing = typeof _enableEditing === 'function' ? _enableEditing(row) : _enableEditing;
// ---> Here you can use the enableEditing variable to conditionally check the edit state
}
..........
...............