Highlighting a row in a table based off of a columns value in a Power Table

I am needing to Highlighting a row in a table based off of a columns value in a power table. I am trying to use a for loop but can't seem to get the script to work. As anyone had any luck with something like this? This is the script I am trying to make work

import system
	
data = self.data
data2 = event.source.parent.getComponent('Power Table').data
# 'data'table and 'data2' is power table
for row in range(data2.getRowCount()):
    reject_number = data2.getValueAt(row, 'RejectNumber')
    for row2 in range(data.getRowCount()):
        ingot_number = data.getValueAt(row2, 'IngotNumber')
        if reject_number == ingot_number:
            event.source.parent.getComponent('Table').style.rowBackground = 'Red'

Vision Power Table's don't have styles like that. That's Perspective.

Implement the configureCell() extension functions. That gets called whenever java Swing needs to paint cells, separately for every cell that is visible (at least). The method can look up the row data for the cell in question to return the desired adjustments to the normal painting operation.

Similar recent topic:

1 Like

so how would I go about setting it up correctly? Adding a custom property as a dataset and referencing that?

If your main dataset has the information needed to decide the styling, simply reference it directly.

Show a sample dataset and describe the styling result you want.

If the IngotNumber and RejectNumber match, then I want to highlight the row red in the Power Table

This data comes from the Data binding of the Power Table

IngotNumber      AvgHeight 
26258	       3.0672528743743896  (This one matches) this row should be red
26257	       3.2045392990112305
26256	       3.179182529449463
26255	       3.177241086959839
26254	       3.1401920318603516
26253	       3.257405996322632
26252	       3.1032402515411377

This data is in the custom property of the Power Table called RejectData

RejectNumber                 DateTm
26258	         Sat May 11 23:15:19 CDT 2024 (This one matches)
26251	         Sat May 11 23:11:19 CDT 2024
26240	         Sat May 11 23:10:37 CDT 2024
26218	         Sat May 11 23:09:33 CDT 2024
26215	         Sat May 11 23:07:21 CDT 2024
26212	         Sat May 11 23:07:02 CDT 2024
26209	         Sat May 11 23:06:44 CDT 2024

Ok, then your configureCell extension method would look something like this:

def configureCell(self, value, textValue, selected, rowIndex, colIndex, colName, rowView, colView):
	rejects = self.RejectData.getColumnAsList(0)
	if self.data.getValueAt(rowIndex, 0) in rejects:
		return {'background': 'red'}

This what I tried but it didn't seem to work.

	import system
	from java.awt import Font
	data = self.data #Data from Power Table
	rejectData = self.RejectData #Reject Data from Power Table custom property
	def configureCell(self, value, textValue, selected, rowIndex, colIndex, colName, rowView, colView):
		rejects = self.RejectData.getColumnAsList(0)
		if self.data.getValueAt(rowIndex, 0) in rejects:
			return {'background': 'red'}

The def configureCell(...) is supplied by the extension method editor. You cannot put anything above that line, nor indent it.

Make sure you are making the actual extension method look like what I supplied.

If you need more functionality, including imports, create a project library script function (preferably not called configureCell) and delegate to it.