Won't Fix
Last Updated: 10 Feb 2021 09:59 by ADMIN
Created on: 28 Jan 2021 10:00
Category: GridView
Type: Bug Report
GridView: The SelectedItem is null when the control is bound to a DataView and grouped by a GridViewComboBoxColumn
The RadGridView's is bound to an empty DataView and grouped by a GridViewComboBoxColumn. When adding items during runtime, setting the SelectedItem in code or selecting through the UI -> the SelectedItem remains null. 
1 comment
Posted on: 10 Feb 2021 09:58


As it turns out this is not an issue. If you are using the following code for adding a new item: 

     var newRow = (this.DataContext as MyViewModel).DataTable.DefaultView.AddNew();
     newRow["FirstName"] = "John";
     newRow["LastName"] = "Doe";
     newRow["JobUnitStatus"] = "C";

a CollectionChanged event is raised before updating the new item (when calling the AddNew method of the DefaultView). RadGridView depends on this event in order to populate its groups. So, in this scenario, it will create a group with an empty Key. Which will results in the wrong behavior at a later stage. If the item is created first and then added in the source collection of the RadGridView, then the group will be created with a proper Key and the issue will not be observed. For example:

    var newRow = (this.DataContext as MyViewModel).DataTable.NewRow();
            newRow["FirstName"] = "John";
            newRow["LastName"] = "Doe";
            newRow["JobUnitStatus"] = "C";
            (this.DataContext as MyViewModel).DataTable.Rows.Add(newRow);

Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.