Hi,
I’m traying to display a table based on a Named Query, and change it background color based on a cell value, but I can’t find anything to do that.
This is my table
How can I change a row background color based on his “Capacidad” value?
Thanks in advance.
Rodrigo
2 Likes
You have to build a transform on the data binding to add a style value to each row. Might not be the most elegant code to get it to work, but works for us.
import json
recipe = value
data = []
list=[]
for row in range(len(recipe)):
ds = recipe[row]
a= ds.a
b= ds.b
c= ds.c
if c:
style = '#87C7E6'
else:
if row%2 == 1:
style = '#FFFFFF'
else:
style = '#E5E5E5'
row={"style":{"backgroundColor":style},"value":{"a":a,"b":b,"c":c}}
list.append(row)
return list
Rodrigo, did you ever get that working?