Change background colour of a cell based on a control field in the same row

I was wondering who could help me with this. I have a column called project_amount in a table called projects and another column in the same table called project_amount_control. The second one is a control checkbox only used for the purpose of specifying the background colour of project_amount and it will not be visible.

I need that for any given row in the table:

  • if project_amount_control = 0 then the background colour of project_amount for that specific row is left unchanged
  • if project_amount_control = 1 then the background colour of project_amount for that row is #F6E5C4

My guess is that I need to enter some if statement in JS in between {{ }} in Background but I have no idea what to enter, so I was wondering who could help me with this.

Thank you so much. :slightly_smiling_face:

Use a ternary operator
{{currentRow.project_amount_control == 1?'#F6E5C4':''}}
https://docs.retool.com/docs/javascript-in-retool#ternaries

1 Like

Thanks @ScottR for teaching me about ternary operators.