[problem relates to what happens after causes data to change position in sorted table, and next cell in original row number to automatically enter editing mode]
I have a multi-column table view fed by a data source. It’s sorted by the first column.
If a user edits one of the rows in that column, and the edit causes that row’s data to move up or down within the table, the selection should follow the moved data. But it doesn’t. The selection stays put even though it’s now covering completely different data than before. Worse, if the edit of that cell was terminated with , the next cell in that row (which now holds completely different data to a moment before the user pressed ) goes into edit mode automatically.
I’d like to find a way to get the selection to follow the moved data. The auto-entering of edit mode on the next column is actually a good thing, but not if the selection doesn’t follow the data.
Example: Prior to editing, the table, which is sorted on the first column, looks like this:
AAA 123
CCC 456
EEE 789 ← user will double click on “EEE”, change it to “BBB”, then press
Now the user double clicks on EEE (so that the third row of the table is selected, and the table view is now editing “EEE”), and changes “EEE” to “BBB”, then press so he can then edit the “789” field. Since the table is sorted, this causes the data visible within the table to jump around so it now looks like this:
AAA 123
BBB 789 <----------------------- …but I want it to be here
CCC 456 <–selection is here…
All well and good. But the selection is still on the third row of the table. I’d like the selection to be on “789”, ie: to follow the data around when it moves.
Note that I’m quite familiar with the “selected data row” function. But what’s happening is that “456” goes into editing mode after I’ve succesfully moved the selection to where it should be. This happens automatically because the table seems to want to automatically edit the next column of the original row number (without realizing that the data has moved).
So, the user edits a cell in a way that will change its order in the table. user presses . My “cell has changed” handler is called. In it, I can successfully cause the selection to follow the moved data. I can see this happen on the screen if I play with update and delay and dialogs in the right way. Then, my “cell has changed” handler finishes. The system then automagically puts the next cell in the original row into edit mode, and in the process of doing so, makes that row the selected one. So it undoes my careful work of making the selection follow the moved data.
This behavior would make perfect sense in an unsorted list, but in a sorted list it doesn’t make sense, at least not to me.
Is there anything I can do to either:
a) make the selection stick with the moved data
b) stop the from automatically putting the next column into edit mode. In this case, I actually want it to go into edit mode automatically (or under my control), but in the moved row.
Sorry if this is a common question. I’ve done a lot of hunting and have not found the answer on-line or in the docs.
Any help much appreciated.
– Dan Freedman