Page 1 of 1

Updating datagrid but keep selected line

Posted: Fri Jul 01, 2022 7:35 pm
by DavJans
I'm trying to keep the selected line after updating a datagrid.

Code: Select all

put the dgHilitedIndex of group "DataGridCutList" into cutlistLine
--Update datagrid
set the dgHilitedLines of group "DataGridCutList" to cutlistLine
This works great until I sort the datagrid. After sorting and selecting line 1 (visually) this happens

Code: Select all

put the dgHilitedIndex of group "DataGridCutList" into cutlistLine
answer cutlistLine  -- the answer is not 1 for this example lets say 2
--Update datagrid
set the dgHilitedLines of group "DataGridCutList" to cutlistLine
--It will hilite whatever line (visually) that the number is, in this case line 2 

Re: Updating datagrid but keep selected line

Posted: Fri Jul 01, 2022 9:20 pm
by Klaus
Hi DavJans,

after sorting dgIndex <> dgLine, but dgIndex = dgIndex!
So I think just restoring the INDEX will solve this inconvenience:

Code: Select all

...
put the dgHilitedIndex of group "DataGridCutList" into cutlistLine
## answer cutlistLine  -- the answer is not 1 for this example lets say 2
## Update datagrid
## set the dgHilitedLines of group "DataGridCutList" to cutlistLine
set the dgHilitedIndex of group "DataGridCutList" to cutlistLine
...
Best

Klaus

Re: Updating datagrid but keep selected line

Posted: Fri Jul 01, 2022 9:31 pm
by DavJans
OMG, what a stupid mistake, thank you