Material-table: Hook to decide whether a cell is editable based on row data

Created on 13 Jun 2019  路  5Comments  路  Source: mbrn/material-table

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)
  }

Most helpful comment

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

All 5 comments

duplicate of #690

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

This is published with 1.39.1

Thanks

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KKrisu picture KKrisu  路  3Comments

revskill10 picture revskill10  路  3Comments

bohrsty picture bohrsty  路  3Comments

ps1011 picture ps1011  路  3Comments

ModPhoenix picture ModPhoenix  路  3Comments