# How to keep a Power Table selectedRow when sorting

**URL:** <https://forum.inductiveautomation.com/t/how-to-keep-a-power-table-selectedrow-when-sorting/27226>\
**Category:** Ignition\
**Tags:** ignition80, vision\
**Created:** [August 7, 2019, 1:11pm UTC](https://forum.inductiveautomation.com/t/how-to-keep-a-power-table-selectedrow-when-sorting/27226 "2019-08-07T13:11:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joel.golinucci](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joel.golinucci/32/9927_2.png) [@joel.golinucci](https://forum.inductiveautomation.com/u/joel.golinucci)\
**Post date:** [August 7, 2019, 1:11pm UTC](https://forum.inductiveautomation.com/t/how-to-keep-a-power-table-selectedrow-when-sorting/27226/1 "2019-08-07T13:11:39Z")

</div>

Hi,

I’m using a script to periodically refresh the content of a powertable. Some columns are the result of an SQL query and some other are tags (and I want the value to be refreshed).

I also want the table to be sortable, and the user’s selected row to be kept.

When the table is not sorted, on my custom method for refresh I used to do this:

```auto
#Memorize the selected row
selectedRow = self.selectedRow

#Do some stuff including generating the new dataset
self.data = theNewDataset #Same size as before

#Restore the selected row
self.selectedRow = selectedRow

```

But as soon as the table is sorted, the selected row keeps changing when it gets restored.

I’m guessing I have to maybe do something with the viewDataset but I don’t know how to get/restore the selected row on the view dataset.

---

<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:** [May 17, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/how-to-keep-a-power-table-selectedrow-when-sorting/27226/2 "2020-05-17T12:39:03Z")

</div>

Late, but for future reference, you might need to call the reselect function in an invokeLater call to ensure it reselects the row after its done updating itself
