Add Conditional Styling to Perspective Table Data Rows
Add conditional styling, such as font color, background color, etc. based on a cell value
Conditional Row Background Color
forEach(
{this.custom.data},
asMap(
'value', it(), // use asMap(it()) for dataset sources
'style', asMap('backgroundColor', if(it()['population'] > 1000000, 'red', ''))
)
)
Features employed
- forEach() Loops through each row..
- asMap() Creates a map of the list of key-value pairs.
- it()['columnName'] Delivers a cell value based on the column name.
Note that for dataset sources, each row needs to use asMap()
for the value
key (see expression comments).