Completed
Last Updated: 19 Feb 2018 15:13 by ADMIN
pavi
Created on: 22 Nov 2017 18:23
Category: GridView
Type: Bug Report
1
GridView: Binding ItemsSource and SelectedItem of GridView changes SelectedItem
I have a RadGridView and bind its ItemsSource and its SelectedItem to properties of the ViewModel (DataContext). I use a ViewModel for the grid items with overridden Equals and GetHashCode. When the ViewModel is created, the property bound to ItemsSource is filled and the property bound to SelectedItem is set to an item that is equal to one of the items in the collection (but not reference equal).

Problem:
When the GridView is displayed, no item is selected.

Note: I already reported this issue before: https://feedback.telerik.com/Project/143/Feedback/Details/227302-binding-itemssource-and-selecteditem-of-gridview-changes-selecteditem
but now I have managed to modify the sample project so that the problem can be reproduced. The difference to the original sample project is that Equals and GetHashCode of the Club ViewModel are overridden and the selected item is not reference equal to the item in the collection.
Attached Files:
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
2 comments
ADMIN
Yoan
Posted on: 19 Feb 2018 15:13
The fix will be available in the R1 2018 SP2 Release.
ADMIN
Ivan Ivanov
Posted on: 29 Nov 2017 13:23
Thank you for reporting this issue. It is related to the fact that RadGridView’s UI virtualization cache works with object.ReferenceEquals, for creating and storing rows. The selection engine correctly assigns the item as a selected one, but none of the rows is actually selected. On the other hand, one of the main collections of RadGridView’s data engine uses object.Equals, which causes some other known issues that are observed when the business item type overrides Equals. We have some plans for introducing changes that will prevent the disparity between regular CLR types and ones that have Equals overridden. However, we will most certainly not include this update in the incoming R1 release. Please, subscribe to this item to track future changes. We will do our best to plan the implementation as soon as possible.