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

**URL:** <https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 7, 2023, 7:56am UTC](https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339 "2023-01-07T07:56:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_SHARIKOV](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Alex\_SHARIKOV](https://forum.inductiveautomation.com/u/Alex_SHARIKOV)\
**Post date:** [January 7, 2023, 7:56am UTC](https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339/1 "2023-01-07T07:56:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![humphrey.daniel](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@humphrey.daniel](https://forum.inductiveautomation.com/u/humphrey.daniel)\
**Post date:** [January 7, 2023, 4:49pm UTC](https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339/2 "2023-01-07T16:49:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alex\_SHARIKOV](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Alex\_SHARIKOV](https://forum.inductiveautomation.com/u/Alex_SHARIKOV)\
**Post date:** [January 8, 2023, 12:35am UTC](https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339/3 "2023-01-08T00:35:45Z")

</div>

This cheap hack is already implemented 😃

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.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 8, 2023, 12:46am UTC](https://forum.inductiveautomation.com/t/setting-table-selection-from-the-script-with-auto-scroll-to-the-selection/68339/4 "2023-01-08T00:46:25Z")

</div>

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