Power table - Help coloring specific cells based on boolean tags value

Hello sirs,
i want to color just one cell of a power table, based on a boolean tag value.

Below you can find the code:

Numeri = [1,2,3,4,5] for x in Numeri: TAG = "[Client]NOK_Pressione_%s" % (x) Valore = system.tag.read(TAG).value if Valore == True: if colName == "Pressioni" and rowIndex == (x - 1): return {'background' : 'yellow'}

Now, with this code i’m able to color the cell, but only if i click on it.

What i would like to accomplish is:
The table should always check if there’s a value change in a tag, then color it’s specific cell automatically, without clicking on the interested cell (all this without the use of a boolean column in the table dataset).

Someone would like to help me?

Thank you, again.

Where is this code currently located?

Sorry, i forgot to say that it’s placed in “onCellEdited” function.

I thought it might be. This code won’t fire until the cell is edited so you should put coloring information in the configureCell extension function.

Sorry again, i was thinking about “onCellEdited” and i wrote the wrong name.

The code is placed in the “configureCell” function.


I see now. I made a workaround but it is a bit ugly. I created a dataset on the root container called ‘data’ to hold the power table data and bound the power table’s Data property though the following expression:

if({[Client]NOK_Pressione_1}=1, {Root Container.data} , {Root Container.data})

This triggers the configureCell extension function when NOK_Pressione_1 changes. You can add in the rest of your tags. I’m sure a more elegant way to trigger the function exists, this is just off the top of my head.

1 Like

Hello, I am trying to accomplish a similar thing:
I want to highlight only one entire row based on a value of a Memory tag called “Value”
This value is tag is changing dynamically.

On the the ConfigureCell property, I have the following scripting code:

Num = self.data.getValueAt(rowIndex,“StepNo”)
value = system.tag.read(“MX_Seating/R1Cx_01B/Value”).value

if Num == value:
return {‘background’: ‘#DDDDDD’}

This works, but not as well because it doesn’t update as soon as my memory tag “Value” changes:
Any suggestion on how to make it update as soon as the tag value changes?
I was thinking of transferring the code to the propertyChange property instead of the ConfigureCell property, but I am stuck:

By the way, my Data for my powertable is coming from a SQL Query.
Your help would be greatly appreciated. Many thanks in advanced.

It finally was clear to me on what you meant to resolve this and make things work:

  1. Right click on the Root Container and create a custom property.
    In my case I called it “test”:
  2. On my “test” property, I input my query:
  3. I drop a power table on the root container and bind the Data to the following expression:

if({MX_Seating/R1Cx_01B/Value}=1,{Root Container.test},{Root Container.test})

  1. On the power table scripting property “ConfigureCell”, I used the following code:

Num = self.data.getValueAt(rowIndex,“StepNo”)
value = system.tag.read(“MX_Seating/R1Cx_01B/Value”).value

if Num == value:
return {‘background’: ‘#DDDDDD’}

  1. Finally, I can manually input a number on my Memory tag value called “Value”, and I will see
    that the row corresponding to that value will be colored:

Thank you very much!

Can’t you just bind the selectedRow property to the Tag Value - 1? Then just change the sectionBackground color.

1 Like

I would strongly suggest you not do a tag read inside a configureCell method–that can dramatically slow rendering of your table. Bind that tag to a custom property and read that in the method instead.


Thank you. That works even better.

Thank you very much.