Right Click Popup on Power Table Not Working

Hey all,

New to Ignition here in these recent couple weeks, and I’m at a loss for ideas as to why my power table suddenly stopped allowing me to right click it, when it’s the same as two others in different windows, and the windows are also largely the same with the same references (the other two allow me to right click them).

What’s supposed to happen is you right click anywhere in the table and it brings up an option to export to spreadsheet (xls format). I know, however, that specifically, the code for exporting to excel itself works because I also have that inside a button to the side. For some reason, the small popup won’t appear at all.

Here is the code I have in the Script Editor in the Mouse Release event for the Power Table:

def exportXLS(event):
	from java.util import Date
	tableName = event.source.parent.getComponent('TableName').text
	now = Date()
	date = system.db.dateFormat(now,"MM-dd-yyyy")
	file = tableName + " " + date
	data = event.source.data
	dataCol = data.getColumnName(0)
	noInfo = "No information found."
	if(dataCol == noInfo):
		system.gui.messageBox("There is no information to export!","Export Failed")
menu = system.gui.createPopupMenu(["Export to Spreadsheet"], [exportXLS])

A little stumped here, and any help/suggestions are appreciated.


Is there any particular reason you’re using the MouseRelease event, rather than the onPopupTrigger extension function?

Dropping your exact code into the onPopupTrigger function worked perfectly (a right click displayed the Export option) for me.

1 Like

Hello Paul

Sorry about this grave digging message: I tried your suggestion (using it in onPopupTrigger) but I get the following error:

Traceback (most recent call last):

  File "<extension-method onPopupTrigger>", line 27, in exportXLS

TypeError: getComponent(): 1st arg can't be coerced to int

Line 27 in my case is the following

	tableName = event.source.parent.getComponent('TableName').text

I’m using a powertable and created the ‘text’ property. Would you be able to help me identify my mistake?


Well, the short answer is that you don’t need an event.source.parent - if you’re already in an extension method, there’s a self reference back to the originating component.

The long answer has to do with Java Swing’s internals:
event.source.parent, from a table, refers to the component itself. The getComponent(<name>) function is only a method on Ignition’s container types - otherwise, you have to use the underlying Java swing method Container.getComponent, which only accepts integers as arguments - each child of a container (and every Java Swing component is a container) is indexed.

1 Like

Thanks Paul, everything’s working now :fist_right: :fist_left: