is there a way to code a button to select all the rows in a table?
If I’m not mistaken:
table = event.source.getComponent("yourtable")
table.selectAll()
Since the Ignition components inherit from Swing components, you can use the functions in the Swing documentation 99% of the time.
no that does not work.
Traceback (innermost last):
File "<event:actionPerformed>", line 2, in ?
AttributeError: selectAll
Hi Jonathan,
Try this:
#this code is on the actionPerformed event of a button in the same container as the table
rowCount = event.source.parent.getComponent('Table').data.rowCount
event.source.parent.getComponent('Table').viewport.view.addRowSelectionInterval(0,rowCount-1)
Dan
Thanks, that works.
So how did you know about the property rowCount on a dataset? How did you know about viewport.view.addRowSelectionInterval()? I do not see any of those in the FactoryPMI or Ignition documentation.
[quote=“Jonathan”]Thanks, that works.
So how did you know about the property rowCount on a dataset? How did you know about viewport.view.addRowSelectionInterval()? I do not see any of those in the FactoryPMI or Ignition documentation.[/quote]
rowCount on DataSet is hiding in the user manual.
The whole viewport.view.addRowSelectionInterval is him accessing the properties of Java Swing components.
See JScrollPane and JTable.
A bit more advanced stuff than usual going on here.
While I have used the java references to figure out how to accomplish some tasks in jython, I most likely adapted this specific piece of code from a post in the forum:
http://inductiveautomation.com/forum/viewtopic.php?p=9502#p9502
Dan