Power Tables - Auto Size Columns

Is there a script / property equivalent to Right Click Header → Auto Resize All Columns? This makes all columns as wide as they need to be to fit the data, even if it causes a horizontal scrollbar. This is the desired result, but the only way I know of causing this to occur is manually doing it every time.

The Auto Resize Mode property basically does the same as above, and then scales all columns down to fit the size of the table, forcing there to be no scrollbar. This is not desired, as strings and numbers are getting concatenated.
The script below is the equivalent of the “Auto Resize Mode” being set to “All Columns”

Ignition 7.8.5

1 Like

The script you want is in the same post you linked to. There maybe an easier way to do this, but I have used this with success. For a power table, use this script in the propertyChange event handler and any time the table data changes the columns will resize accordingly.

if event.propertyName == 'data':
	#This code resizes a wide table with the scroll bar
	from com.jidesoft.grid import TableUtils
	from javax.swing import JTable
	table = system.gui.getParentWindow(event).getComponentForPath('Root Container.TableName').getTable()
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
	TableUtils.autoResizeAllColumns(table)
4 Likes

Thank you! The last line is the part that I needed

2 Likes

Thanks, i was looking for a similar function and this worked with almost just a copy paste, only changing the power table name.

1 Like