redo all tabs(indents), indents often gets broken when copying.
python needs indents after if:
I think this would work for your original question:
same result as @victordcq but more verbose
# initialize an empty dictionary for rows that will not have a background color change
formatDictionary = {'background': 'white'}
# only look at Batch Element ID
if colName == 'Batch Element ID':
# get data from Batch Element ID and corresponding Duration
batchElement = self.data.getValueAt( rowIndex, 'Batch Element ID' )
duration = self.data.getValueAt( rowIndex, 'Duration' )
# determine if the row should be red
if (batchElement == 'WtrFill1' and duration > 50) or (batchElement == 'AggFill1' and duration > 22)
formatDictionary = {'background': 'red'}
return formatDictionary
i advice to put brackets around âandâ aswell.
My code worked for the test data he provided. The indent error is just a typo thing for sure.
You answer is a bit more elegant i guess^^ but judging from the number of colmuns in the table, i would use elif isntead of âorâ⌠else that will become a long line of code
Another approach, using a second dataset to hold the setpoints for ease of future maintenance:
cell = {'background': self.background}
batchID = self.data.getValueAt(rowIndex, 'Batch Element ID')
setpointID = self.Setpoints.binarySearch(0, batchID)
if setpointID != -1:
duration = self.data.getValueAt(rowIndex, 'Duration')
setpoint = self.Setpoints.getValueAt(setpointID, 1)
if duration > setpoint:
cell["background"] = system.gui.color(255,0, 0)
return cell

Thank you that worked
How do you set up the 2nd dataset. I have never done that.
Easiest way: Right click the component and select Customizers â Custom Properties. Make a property called âSetpointsâ with type Dataset to match my example above. Youâll have to remove the default value column and define your own columns BatchId and SetPoint, using appropriate data types.
Once itâs defined, youâll see your custom property in the property editor just like the standard properties:

Thank you Sir
I did that and it works but only the WtrFill1 changes color the AggFill1 doesnât