material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Hook to decide whether a cell is editable based on row data

Open mohitmutha opened this issue 7 years ago • 5 comments

We have a requirement where we want to edit only certain cells in the row based on other properties in the data

for e.g. if the category of a particular row is VIP then the name and age can be edited and if the category is Normal then only the name can be edited.

I did not find any possibility to do this in the current implementation.

Suggestion for implementation

  • All specifying a function for the editable property in column definition .
  • In the MTableEditRow class add the below in the renderColumns function
 if (typeof columnDef.editable == 'function'){
    allowEditing = columnDef.editable(columnDef, this.props.data)
  }

mohitmutha avatar Jun 13 '19 08:06 mohitmutha

duplicate of #690

mohitmutha avatar Jun 13 '19 10:06 mohitmutha

I merged your pr. Thanks for contribution. I will publish it tomorrow.

mbrn avatar Jun 13 '19 11:06 mbrn

This is published with 1.39.1

mbrn avatar Jun 14 '19 05:06 mbrn

Thanks

mohitmutha avatar Jun 14 '19 06:06 mohitmutha

Was an example on how to use this new feature added to the documentation, or does anyone have an example?

theodore-koch avatar Jul 01 '19 20:07 theodore-koch