Markus Hastreiter
03.09.2009
I've now attached the sample program.
Hi Paul,
I'm sorry but I disagree. As far as I understand your code (and I can only look at it using reflector) there is a class CurrentAndSelectedRowsKeeper that's specifically trying to store the selected and focused rows and to restore them after an update. And it does work as long as the view displays the data unordered (thus it's the same order as in the underlying datasource). The focused row is maintained.
It does not work as soon as the view displays the data ordered (e.g. alphabetically). The CurrentAndSelectedRowsKeeper seems to get confused. It doesn't seem to respect the ordered state. In fact I think I'm able to describe whats going on. Let's say I focus the 3nd row (= index 2 of the ordered elements). But it looks like the value that is stored before the update is the one on the second index of the original (unordered) datasource. After the update of the datasource the then focused row is always exactly the one with _this_ previously stored value.
I'm sorry, it's hard to describe it but I was hoping that the attached flash video would show.
This is why I think that the gridview is trying to focus the "correct" row after an update but it just uses a wrong value to find the desired row.
Could you please look into that again?
BTW: I agree that the "correct" row cannot be determined as long as the data is not unique. But in my case the objects in the datasource are unique so I could write code that finds the row which displays the desired data object and set it as the focused row after an update. But I would expect the grid to do this for me. Or at least there should be an option for this.
A colleague using your Delphi components told me that there exists a function called "IsRecordIdSupported" (along with "GetRecordId") on TcxCustomDataSource for this purpose.
Thanks a lot,
Markus
Hello Markus,
Please note that in WinForms record key values are not provided. It's not a grid's bug definitely. In your instance please handle the GridView.FocusedRowChanged event obtain an underlying record using the GridView.GetRow() method and restore the cursor as you need when a grid's data source is changed.
Thank you,
Paul
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+