RadGridView Filtering Bug

1 Answer 146 Views
GridView
James
Top achievements
Rank 1
Veteran
James asked on 03 Nov 2022, 05:27 PM | edited on 03 Nov 2022, 05:28 PM

There is a bug in the RadGridView when using built in filters.

If I filter a grid by a value that returns a single row, the row is visibly selected but and I get a System.NullReferenceException, if I try to get a cell value when the SelectionChanged event is fired.  When I handle the exception, and I then click on the row, it does not fire the SelectionChanged event.

I have to set .CurrentRow = Nothing on FilterChanged in order to click on and select the row, which will then fire the SelectChanged event and I get the value expected.

Here is my relevant code to reproduce the issue;

 

Private Sub RadGridViewFullBadge_SelectionChanged(sender As Object, e As EventArgs) Handles RadGridViewFullBadge.SelectionChanged

            'This If Statement is Required or I get a System.NullReferenceException after the filter is applied

            If RadGridViewFullBadge.CurrentRow IsNot Nothing Then
                RadTextBoxControlTestBadge.Text = RadGridViewFullBadge.CurrentRow.Cells("BadgeID").Value
            End If

    End Sub

    Private Sub RadGridViewFullBadge_FilterChanged(sender As Object, e As GridViewCollectionChangedEventArgs) Handles RadGridViewFullBadge.FilterChanged
        RadGridViewFullBadge.CurrentRow = Nothing
    End Sub

 

James

           

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Nov 2022, 09:10 AM
Hello, James,     

Following the provided code snippet, I have prepared a sample project to test the behavior on my end. Setting the CurrentRow to null in the FilterChanged event actually closes the editor after each key pressed if you intend to type several letters in the filter cell. I would like to note that there is a difference between a selected and a current row. More information can be found here:
https://docs.telerik.com/devtools/winforms/controls/gridview/rows/selected-rows-and-current-row 
You may have multiple rows selected, but only a single row can be current. That is why accessing a cell value by using the CurrentRow in the SelectionChanged event, is expected to ensure that the CurrentRow is not null. Hence, the null check is fine.

I have attached my sample project for your reference. Could you please specify the exact steps how to reproduce the problem? Do I need to perform any changes in the code to reproduce the experienced issue? Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
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/.

James
Top achievements
Rank 1
Veteran
commented on 09 Nov 2022, 12:54 PM | edited

Add to RadForm1_OnLoad

        Me.RadGridView1.ShowFilteringRow = False
        Me.RadGridView1.ShowHeaderCellButtons = True

Remove the RadGridView1_FilterChanged event'

Run the program.

Filter the ProductName column for "Aniseed Syrup", and you will see that Me.Text does not change when the filter is applied. If you click on the row Me.Text does not change. 

This seems like a bug to me.

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 11 Nov 2022, 03:26 PM

Hello, James,     

I have made the described modifications in my sample project and tracked the program's execution when filtering by using the Excel-like filter popup. The appropriate event here is the CurrentRowChanged event which is fired after the FilterExpression is successfully applied and the rows in RadGridView are filtered.  

    Private Sub RadGridView1_CurrentRowChanged(sender As Object, e As CurrentRowChangedEventArgs)
        If RadGridView1.CurrentRow IsNot Nothing Then
            Me.Text = RadGridView1.CurrentRow.Cells("ProductName").Value
        End If
    End Sub

Tags
GridView
Asked by
James
Top achievements
Rank 1
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or