[Perspective] Table Highlight Row Based on Property Name or Text

I am looking for a way to highlight the row that matches the string below. I am querying a database for the info. Desired output:

The standard way to do that is to run a script transform on the value returned by the data binding - assuming that your table data is the result of an SQL query of some type. The transform will modify the style of the selected row. Have a look at the data structure of the table component’s default data and, in particular, the Folsom highlighting.

There’s a little more in Perspective - Table - Ignition User Manual 8.1 - Ignition Documentation under the data properties.

city: {
  value: 'Folsom',
  editable: true,
  style: {
    backgroundColor: 'grey',
    classes: [] | ''
  }
}

Yes . i didnt scroll far enough haha >>>

def transform(self, value, quality, timestamp):
“”"
Transform the incoming value and return a result.

Arguments:
	self: A reference to the component this binding is configured on.
	value: The incoming value from the binding or the previous transform.
	quality: The quality code of the incoming value.
	timestamp: The timestamp of the incoming value as a java.util.Date
"""

	# This list will be used to create a JSON like structure that will insert rows for our styles
output_json = []
		 
		# Here we can define what styling on our rows will be.
style_orange = {"backgroundColor": "#ff9900", "fontWeight": "bold", "fontSize": 35}
style_black = {"backgroundColor": "#000000", "color": "#ff9900", "fontSize": 20}
		 
		# You could change more than just the background color, for example:
		# style_another_example {"backgroundColor": "#00AA00", "font-weight": "bold"}
		 
		 
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
		         
		        # Here we're checking the name of the column that we want to base our styling on.
		    if value.getColumnName(col) == 'Login':
		         
		            # Here we're checking for individual values within the column, and applying styling
		        if value.getValueAt(row, col) == "MROEL":
		            row_style = style_orange
		        else :
		          row_style = style_black
		                 
		    row_object['style'] = row_style
		output_json.append(row_object)
return output_json

1 Like