Changing background color specific rows and cells

How can I change the background color of a specific row based on the value of a data element in the row?

For example, in the Fakedata that comes with the datagrid element, how can I change the background color of rows where Quantity > 45?

When I ask AI, it used a variable call “Folder” which does not actually exist.

Hi, you can simply use the plug icon next to the color value and create a formula, for example:

By the way this is the ternary syntax, in case you might be confused. JavaScript Ternary Operator – Syntax and Example Use Case

2 Likes

Thanks @Broberto!

I see the binding but I seem unable to access the Item.data.row.Quantity data element in that binding. I believe (please tell me if I am incorrect) your example uses a variable external to the collection.

Hi, yes I use whatever came under my hand to provide the example above. I’m not sure about your specific case though. Can you share some more context?

No issue at all. I just wanted to make sure I understood the example.

Your example made me realize I can use the custom Type to access the row data instead of Text to access the specific data in the row. That allowed me to get to the row level data and set the cell background as need.

Thanks again!

2 Likes

That would indeed be what I’d do :slight_smile: Good job.