Getting a value from a table's self.data

I’m currently trying to accomplish two things in a regular table:

  1. Using propertyChange scripting, I want to make it so that when a selected row’s value is in an array of items I want to exclude, a messageBox pops up to tell the user that item is deprecated, as well as make the selected row value equal to -1
  2. Using getForegroundAt under extension functions, I’d like to be able to return a grey for values that are in this same array.

This is what I have for each function

  1. propertyChange

if event.propertyName=='selectedRow':
		currValue = self.data.getValueAt(event.source.selectedRow,event.source.selectedColumn)
		if currValue in deprecatedValues: #deprecatedValues is an array of values
			system.gui.messageBox("Sorry, this value is no longer used. Please select a new one")
			event.source.selectedRow =- 1 ```


2.getForegroundAt
```	currValue = self.data.getValueAt(row,col)
	if currValue in deprecatedValues:
		return 'grey'
	else:
	return defaultColor

The error I’m running into is “NameError: name ‘self’ is not defined”
This refers to my lines of

		currValue = self.data.getValueAt(event.source.selectedRow,event.source.selectedColumn)

Is this not how I should access these values?

The propertyChange does not have a variable self

Instead you’ll need to get a reference to the table component, something like:

data = event.source.data

or if the property change is not on the table:

data = event.source.parent.getComponent(“Table”).data

The easiest way is to use the property browser to get a reference to the property you want

1 Like