Hi,
I have an UltraGrid that is bound to a datasource that changes in realtime. By realtime i mean that rows can be added or removed to the datasource. Supposing I have rows A,B,C,D,E,F,G,H,I. I select rows C,D with D being the active. If row I gets deleted, the selected row shifts to E and on subsequent deletes to the datasource, the selection keeps shifting down to F, G, H etc.
To re-iterate my datasource is changing from the backend, the user is not deleting.
What could this reselection be due to?
Infragistics version: 10.3
Any help would be really appreciated.
It sounds to me like your DataSource is doing things it should not be doing. If your data source sends a reset notification, then the grid will lost everything. It has to. That's what reset means. The grid has to throw away ALL of the data and essentially create an entire set of new rows based on the new data. It will lose selection, sorting, filter, etc.
But a remove shouldn't automatically cause a reset. If that's happening, then something else in your code is triggering the Reset, or else your data source is doing something wrong.
Also this happens when you have selections towards the end of the grid, and rows at the top get deleted. So if row Y towards the bottom at index 99 is selected, it looks like Y(unselected now) has shifted up but index 99 stays selected. Does the grid decide the selection based on index?
The BeforeSelect/AfterSelect are not called at all- they seem to be only fired during user selection.
The issue here is that the code somewhere internally changes the grid.selectedRows.
The event RowsCollection.Remove() of the DataView is causing the ListChange event to fire with ListChangeType.Reset. At this point i notice my grid.Selected.Rows collection picks up something else.
What's the ViewModel? This is Windows Forms, right? So I don't know what ViewModel you are using or what it's doing. Did you mean the DataView? I wasn't aware that the DataView had any concept of selected rows. But whether it does or not, the selected rows in the grid are completely separate. It might be helpful to simply put a breakpoint in the grid's BeforeSelectChange event. Enable the breakpoint right before you delete the row and see if that event is firing and what the call stack looks like.
So should I look out for changes to grid.selected.rows or viewmodel.selectedRows?