Selected row changes after form submission

I have a table with users (uses getUsers query) and a form for updating the selected user (uses updateUser query which triggers getUsers query after success). The issue is that when I submit the edit form it updates the user in DB, refreshes the table and selected row changes on random user. Sometimes it stays on the previous user as expected but usually it changes. Can this behaviour be disabled or controlled?

Yes this can be done.

Create a temp state and set that value to {{table5.selectedRow.index}}

Then in the table component set the default row to the tempState value you can always override it as well.

seems like it doesn't work. first, it warns cycle dependency is found. second, after the submission the selected rows changes as in original post

Yes, I noticed the cycle dependency but the row selected did not change for me upon running the query that populates the table. When the table refreshes, are you certain that the same number of rows are populated?

Hi, I´m having the same issue... I tried the temp state workaround, but not only does it throw a dependency error, it also doesn't keep the same row selected. Is there another way to make sure the selected row is the same following a form submission?
Could we for instance select the row based on the id of the previously selected row?

Hey @Alexia_Danan! Would you mind sharing a screenshot of your current setup? I think we should be able to get this to work for you :slight_smile:

@victoria thanks :slight_smile: well for now not much to show, since I tried index /none as default values and it doesnt work but here it is (just fyi i would like a sort order on my table hence index values may change if advance_date is updated via the form)

I think this is working for me!

1. In an event handler, I set a temporary state to a unique part of the selectedRow (e.g. an ID)

2. I set the default index of the table to be the index of the location of that unique id

Would something like this work for you perhaps?