Conditional Formatting for Table

Hi All,

I've just set up my first App for Retool and currently experimenting, seem to be doing OK in regards to showing what information I want but I'm having a bit of difficulty with conditional formatting on a table.

The table I have has three columns.
ID (hidden)
Inspection Title
Inspection Due Date

I'd like it so anything that is due in the next 7 days will have an orange row background.
Anything overdue (dated before (Today)) would be red.

Format of the Due Date is just 'Date'.

How would be best to achieve this please?

image

You can do this by changing the background (for example) with some code to evaluate your criteria:

I used {{new Date(currentSourceRow.createdAt) > new Date(new Date().setFullYear(new Date().getFullYear() - 2)) ? 'red' : 'green'}} since the dates in my demo table are old.

You might use something like {{new Date(currentSourceRow.InspectionDueDate) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) ? 'orange' : undefined}} which would leave the background blank for all other rows.

1 Like