Hello everyone!
I am using a property change script to write data to a table. I then need to add a transform to modify the colors of the rows of the table depending on the value inside of them. When Trigger becomes True, it runs a query and moves that data into the table. I did it this way so that I could parameterize the query that it runs.
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
if previousValue and (previousValue.value != currentValue.value):
TableData = system.db.runNamedQuery(self.view.params.NamedQueryName)
self.getSibling("Table").props.data = TableData
Here is the code that works as a transform to change the table row colors:
def transform(self, value, quality, timestamp):
output_json = []
style_orange = {"backgroundColor": "#d61a3c"}
style_green = {"backgroundColor": "#00b050"}
for row in range(value.getRowCount()):
row_object = {}
row_value = {}
row_style = {}
for col in range(value.getColumnCount()):
row_value[value.getColumnName(col)] = value.getValueAt(row, col)
row_object['value'] = row_value
if value.getColumnName(col) == 'CycleDelta':
if value.getValueAt(row, col) < 0:
row_style = style_orange
elif value.getValueAt(row, col) >= 0:
row_style = style_green
row_object['style'] = row_style
output_json.append(row_object)
return output_json
Is there a way for me to add the transform?