Horizontal Scroll Bar

I have updated a report that displays data for the last 7 days in a table to allow the user to choose start and end dates as they want to be able to choose a 30 day period.
Now my table is not display 30 days data correctly it is all been squashed into the existing size of the table although I run a script to set the width of each column after the data is created.
Is there any way to add horizontal scroll bars to a table or if not how can I force the table columns to a fixed width. The name of the headers and the number of them change depending on the selected dates so the column widths have to be set in a script.

You can change the Auto-Resize property of the table to “Off” instead of the default “Subsequent Columns” which should allow the data to scroll freely horizontally if it doesn’t fit already.

If you want to have that scrollbar always visible (though not necessarily enabled) even if the content fits in the table, you can set the horizontal scroll bar policy to “always” for the scrollpane like this:

from javax.swing import JScrollPane #Assuming event.source is the table component scrollPane = event.source.getViewport().getParent() scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)

For setting column widths using code, something like this will do the trick:

#Assuming event.source is the table component
#[ignition table component].getViewport().getView() will give us the actual javax.swing.JTable object

jtable = event.source.getViewport().getView()

#Traverse the columns of the JTable and assign preferred widths
for i in range(jtable.getColumnCount()):
	col = jtable.getColumnModel().getColumn(i)
	if jtable.getColumnName(i) == "col 1":
		col.setPreferredWidth(50)
	elif jtable.getColumnName(i) == "col 3":
		col.setPreferredWidth(75)
	elif jtable.getColumnName(i) == "col 4":
		col.setPreferredWidth(200)
	else:
		col.setPreferredWidth(100)

Note that you can also reference the column index by using just [tt]i[/tt] instead of [tt]jtable.getColumnName(i)[/tt] in your conditions.

That did it thanks.