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

I went a little bit further to get my value. I could not find much information except these to links on different way to use onPopupTrigger()

Support page
and
Documentation

what worked for me after many many trial and errors:

ValueNeeded= self.parent.getComponent('Power Table').data.getValueAt(rowIndex, "SQLdataBaseColName")

Edit: how I found this out

  1. Went to the power table component docs to see what properties I could use on it

  2. saw I could use .data and needed to find what methods go with that and I went here to find that

  3. just trial and error or trying different ways to grab data from a sql database. Failed at getting anything that wasn’t in the table itself. Remedy, add all columns needed and just hide the one we don’t need