Setting table selection from the script with auto scroll to the selection

I have a table components in a Perspective View. The data property is bound to a tag with dataset data type. There is a button in the same View which creates a new row in an SQL table. When the row added successfully to the table it calls the tag refresh function. This function gets the table from SQL and writes to the tag. As the tag is bound with the table data property, the table shows updated table with the new row.

When the table grows the newly added row is at the bottom of the table and hidden by the scroll viewport. So it needs to be scrolled down.

Question: is there a correct way to set the selection so it scrolls to the selected row?

I tried so far to set table.selection.selectedRow but it doesn't scroll down.

Don't have the specific answer you asked for.

When working with lists of information, consider if reversing the order solves your problem. In this case, showing newest on top.

I've had many instances where looping from the end to the start of data did what I needed and was simpler code.

This cheap hack is already implemented :smiley:

The problem is still here when the user wants to sort the table their way and then adds a new item. This item gets buried somewhere in the scrollable area.

There's a feature request for this already, I'll dig it up later

1 Like