Default table view at bottom

Hi,

I am looking for a way to have the default view of a Power Table be focused to the last row of a table. The table is pulling data from a SQL table and I currently have the default Selected Row to be:

SELECT COUNT(*) - 1
FROM tableName
WHERE colName = {selectedStringValue}

This seems to work fine but does not force the table view to show that row. Is there any formatting option for this?

I essentially want the table to scroll up with new entries instead of down.

Thanks,

Michael

I can get it to work from a button with the following script, but the window event handlers seem to be overriding this (I see the scroll jump down and then jump back up).

Is there a better event handler (vs InternalFrameActivated, InternalFrameOpened, or VisionWindowOpened) for this type of script that will just set the default view to the bottom?

from javax.swing import JTable

table = event.source.rootContainer.getComponent("Power Table")
myJTable = table.getTable()
targetRow = 9999999
rectangle = myJTable.getCellRect(targetRow,0,0) 
myJTable.scrollRectToVisible(rectangle)

Okay, it seems to work with the InternalFrameActivated event handler but only scrolls to the second to last row. When I have it triggered with a button event handler the Viewport goes all the way to the bottom as I want. What gives?

I believe it has something to do with window size? It works when the window is made much smaller.

InvokeLater seems to help, but any future input would be appreciated.

def scrollTo():
	from javax.swing import JTable
	table = event.source.rootContainer.getComponent('Power Table')
	myJTable = table.getTable()
	targetRow = 100000001
	rectangle = myJTable.getCellRect(targetRow,0,0) 
	myJTable.scrollRectToVisible(rectangle)
system.util.invokeLater(scrollTo,100)

By the way we are trying to get this to run on Mobile via a windows browser.

invokeLater probably is the “right” solution - there’s an inherent race between the data property updating, which will then fire the binding on selectedRow, which probably completes before the data binding has finished evaluating and put all the rows into the actual table dataset. invokeLater gives the data property time to finish its workload before trying to scroll the table.

Great, thank you very much!