Make a table's cell editable conditionally

Hi,
Is it possible to make a certain cell in a table editable or non-editable based on certain condition?
Ex:- If I have a table which has 5 row and 5 cols. I want to check if cell at row #3, Col#2 has a particular value, then make it non-editable.
Condition in just an example.

Thanks,
Ajay

Yes, you can.

The docs provide this example, where this specific cell is editable:

city: {
   value: 'Folsom',
   editable: true,
   style: {
     backgroundColor: 'grey',
     classes: [] |''
   }
} 

Pay careful attention to the structure of this cell, as it belongs to a greater row entry, likely something like this:

{
    country: 'United States',
    city: {
       value: 'Folsom',
       editable: true,  # json bool is lower-case
       style: {
         backgroundColor: 'grey',
         classes: ''
       },
    population: 85000
} 

Notice that not every cell needs to have this same structure, though a homogenous approach/structure to your cells would really only benefit you in the long run.

You would need to provide this structure as you provide your data to the Table. This is most often done within a transform as part of your binding.

# assuming a list of flat objects
for row in value:
    if row["MyColumn"] == "ValueMayNotBeEdited":
        row["MyColumn"] = {"value": row["MyColumn"], "editable": False}
return value
1 Like

Sorry if I am misunderstanding but we don't have to modify the columns settings, we can add an editable:false to the data?

I guess I can just try it out but I am trying to save some work. thanks

The columns settings apply to the whole column. You want "per cell".

1 Like

Thanks, I tried it out after the post and it worked.