I’m writing a script for a table but I haven’t been able to understand how the getForegroundAt function works. Does it work for individual rows/cells? Or will it only ever return for the entire component? My current script looks like this
for i in range (20):
currValue = self.data.getValueAt(i, 2)
if currValue in deprecatedValues: #deprecatedValues is an array of values
return {'foreground': '#EAE6E6'}
else:
return defaultColor
But it returns the text color for the entire component, is it possible to return for only one row at a time using the table component? (I’m not looking to use power tables, which I know have this functionality)
Don’t iterate. The component does the iteration and calls the function for you, separately, for each visible cell. You provide the answer for the row and column that the component is asking for.
Don’t do anything in these functions that gets non-local data (like from the gateway). A callout across the network will crush your display.
1 Like
Thanks, between this advice and doing return 'gray'
instead of my previous return, I got it to do what I needed!
Is there an equivalent function that can be used for a power table?
Edit:
The answer is yes, using ConfigureCell
if selected:
background = self.selectionBackground
foreground = self.selectionForeground
elif rowView % 2 == 0:
background = 'white'
foreground = 'black'
else:
background = '#FFFFCC'
foreground = 'black'
currValue = self.data.getValueAt(rowView,'EventPassed')
if currValue != True:
foreground = 'red'
return {'foreground': foreground,'background': background}