Conditional edit of cell

Hello!

I have been working with retool for a while now.
Right now I want to make a cell editable in the role column only if it is selected.

I tried the following code:

{{ rt_expertAttendance_table.selectedRows.some(row => row.id === currentSourceRow.id) }}

in the editable field of the column, but it lets me edit even without selecting the row.
here are the table infos that I have:

role column:

table:

Addtionally, said role is from my database which has the enum datatype and I want to have specific colors accordingly. I used this code under the colors field in the option list, but this unfortunately doesnt work as well:

{{ 
  (() => {
    const roles = Array.isArray(show_roles_attendance_ac.value) 
      ? show_roles_attendance_ac.value 
      : [];

    const baseColors = ["#b7db7a", "#7fbf3f", "#4f8f2f", "#2f5f1f"];

    return roles.reduce((acc, role, i) => {
      acc[role] = baseColors[i % baseColors.length];
      return acc;
    }, {});
  })()
}}
1 Like

Hi @Katunga ,

I understand the issue you’re facing—I’ve encountered something similar before. I was able to resolve it using the following forum discussion:

For dynamically setting cell colors, you can refer to this thread for the logic:

You can adapt the approaches from these posts based on your data and use case. If you still face any issues after trying this, feel free to reach out—I’ll be happy to help further.

Let us know if you have any additional questions, @Katunga!