Scripting Row Background color

So I have gotten a little stuck in scripting for changing the background color of entire rows in a table (I am using a standard table not a Power table).

I would like it to iterate through the rows of my existing table and change the background of specific rows using conditional statements. This code is executed using a button.

I am uncertain how to go about this, but this is my best guess about how I think the code might go

event.source.parent.getComponent('TableT3').data = dataOut

for row in dataOut:
    rowData = list(row)
	if row[4] == "11/9/2018":
		event.source.getComponent("TableT3").background = system.gui.color("Red")
	if row[4] == "11/8/2018":
		event.source.getComponent("TableT3").background = system.gui.color("Yellow")
	if row [4] == "11/7/2018":
		event.source.getComponent("TableT3").background = system.gui.color("Green")

An error message appears for the for loop: Object is not able to iterate

Thanks in Advance

try changing dataOut into a pydataset before iterating…

pydata = system.dataset.toPyDataSet(dataOut) 

also it should be

 dataOut = event.source.parent.getComponent('TableT3').data 

That seemed to assist with the beginning of the for loop, but I still get an error in this line of code

Error Message: 1st arg can’t be coerced to int

On those lines, you’re missing a .parent before getComponent like you have in the dataOut assignment. Add that and you should be good to go.

Ah good catch! I feel dumb. Thanks for your guy’s help

I am having a new problem however. When a input all of the same date in, it turns them the correct color. However if I mix and match dates it defaults to the yellow color. Does anyone know why this is?

For what I can tell its taking the last date in the table then making the rest of the rows correspond to the date color.

Your script is setting the background color of the entire table, not the color of a row.

Coloring individual cells or rows is much more difficult to do on a standard table as opposed to a power table.

Is it possible to do on a standard table? And do you know how to go about doing it?

You would need to use the table customizer.

https://docs.inductiveautomation.com/display/DOC79/Table+Customizer