Power Table Drop Down List with ability to enter new text?

Using Ignition 7.9.0 on windows 7 x64

I have a power table that has a vendor column. What I’d like to do is give an authorized user the option of selecting from a list of existing vendors or just enter in their own. Right now, under the confgureEditor extension Functions I have the following code:

[code] if colName == ‘vendor’:
# Create a list of Areas and Bays via SQL Query
query = “SELECT DISTINCT vendor FROM assets”
vlist = system.db.runPrepQuery(query)

	#move the data into a python list
	vendorList = []
	for row in vlist:
		thisList = []
		for item in row:
			thisList.append(item)
		vendorList.append(thisList)
	return {'options': vendorList}[/code]

This works fine for creating a drop down list of my existing vendors, but it doesn’t allow users to enter in new text. Is there anyway to merge the two options or do I have to choose one or the other?

1 Like

I’m not sure if this would work but I would try:

  1. Add a “New Vendor” item to the list.
  2. Add code in the onCellEdited Extension function that opens a popup to let the user create the new vendor there if the value of the cell is “New Vendor.”

Excellent idea! I went ahead and implemented this, but once I did it, the new value is not displayed on the drop down list (apparently configureEditor is only called when the table is first loaded?). When I try to call the function from onCellEdited with

self.configureEditor(self, colIndex, colName)

or

self.configureEditor()

I get an error message stating that the power table has no such attribute. Are extension functions non-accessible?

I’m not happy with it, but the way I’ve solved the problem is in onCellEdited after I add the new item I call system.nav.closeWindow(“Window Name”) and then immediately call system.nav.openWindow(“Window Name”)

It leaves the currently selected cell selected, and forces the table to be reinvoked thus getting the new data (it sure would be nice If I could call configureEditor myself, if only I had votes left over at the ideas page :laughing: )