How to keep a Power Table selectedRow when sorting


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:

#Memorize the selected row
selectedRow = self.selectedRow

#Do some stuff including generating the new dataset = 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.

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