What triggers configureCell on a powertable?

I have a table that lists out a sequence of steps the PLC is going through. I want to highlight the current step that is being run and to grey out the previous steps and right now I have a custom property on my table that is bound to the PLC tag that says what step it is on like this

and in my configureCell I have the following script -

	try:
		curStep = self.currentSequenceStep - 1
		if rowIndex < curStep:
			return {'background':'grey'}
		elif rowIndex == curStep:
			return {'background':'green'}
		else:
			return {'background':'white'}
	except TypeError:
		# Occurs sometimes on initial loading before tag is found so this is just to
		# keep the console from getting flooded with useless errors
		pass

It would be nice IMO if the extension function documentation

Provides a chance to configure the contents of each cell. Return a
	dictionary of name-value pairs with the desired attributes. Available
	attributes include: 'background', 'border', 'font', 'foreground',
	'horizontalAlignment', 'iconPath', 'text', 'toolTipText',
	'verticalAlignment'

said what it was that made it trigger and run this. I know a data property change seems to consistently trigger it but not sure what else.

The behavior I am experiencing now is that the step will increment, but the table does not seem to reflect the changes until the user clicks on the table and then it is up to date (and even then sometimes it requires multiple clicks for some reason).

I am wondering if there is a different way to set this up, of if there’s a way I can leverage a prop change on my custom property that would be like

if event.propertyName == 'currentSequenceStep':
    # Tell table to configureCells again

I am using 8.1.3 if that matters.

I would add a hidden column to the table data property called something like activeStep

Then in your property change event set the appropriate rows activeStep to True (and the previous to False)

Then it should force configureCell to fire. I don’t know of any other way to force it other than updating the data on the table (or trying to interacting with it)

1 Like

I was trying to avoid this as I use the underlying dataset every all over in scripting and adding a essentially a dummy column just for visualization is going mess with some other scripts I think. If there is no other reliable way then I will do that, that was my first idea, but I was hoping there would be a different way. Maybe with some java magic.

I totally understand! I always end up with a bunch of hidden columns in my dataset just to force configureCell updates so hopefully there is another way to make it trigger again

1 Like

Ok so luckily the way I work with this table is I have a root container custom property that has the complete raw dataset that I make look pretty and then assign to the table like this

if event.propertyName == "sequenceStepData":
	destinationDS = system.dataset.toDataSet(["Step Number", "Step Type", "Params"], [])
	# Chance to proceess new data and make viewable for table
	ds = system.dataset.toPyDataSet(event.newValue)
	for (col1, ..., colN) in ds:
            # Make desintationDS look pretty for the table
	event.source.getComponent('Table_Sequence').data = destinationDS

All I did was add another custom property called reconfigureCells on the root container. Then I changed my script to look like

if event.propertyName == "sequenceStepData" or event.propertyName == "reconfigureCells":
	destinationDS = system.dataset.toDataSet(["Step Number", "Step Type", "Params"], [])
	# Chance to proceess new data and make viewable for table
    if event.propertyName == "sequenceStepData":
        ds = system.dataset.toPyDataSet(event.newValue)
    else:
        ds = system.dataset.toPyDataSet(event.source.sequenceStepData)
	for (col1, ..., colN) in ds:
        # Make desintationDS look pretty for the table
	event.source.getComponent('Table_Sequence').data = destinationDS

And then on my table as a proeprtyChange I have

if event.propertyName == 'currentSequenceStep':
	event.source.parent.reconfigureCells=True
	event.source.parent.reconfigureCells=False

So now every time the step counter increments, the table tells triggers the root container property to redo the script that makes the raw dataset presentable whether or not the data changed and then sets it to the table. At that point I think the Ignition table sees a new dataset assigned and reruns configure cells regardless of the fact that I am assigning an identical dataset to the .data property. This works nicely!

1 Like

I would expect something like this to work:


from org.apache.commons.lang3.reflect import FieldUtils

model = FieldUtils.readField(powerTableReference, "model", True)
model.fireTableDataChanged()
3 Likes

There’s that java magic I was hoping for. I will try it this way and see how it goes.

Edit: Works perfectly. Now my root container property change remains in the original state to only modify the data instead of running for two different scenarios which I appreciate and my table property change is able to directly trigger it like

if event.propertyName == 'currentSequenceStep':
    # This tells the configureCell extension function to run again
	from org.apache.commons.lang3.reflect import FieldUtils
	model = FieldUtils.readField(event.source, "model", True)
	model.fireTableDataChanged()

This is awesome! Thank you Paul :smiley:

Thanks! This is a great solution