Last Updated: 28 Jun 2019 08:50 by ADMIN
Release R2 2019 SP1
Created on: 03 Jun 2019 14:22
Category: GridView
Type: Bug Report
Excel-like filtering of datetime columns doesn't work
RadGridView data source contains date values from years 2018 and 2019. After adding Excel like filters to the RadGridView and selecting year 2019 no rows were displayed, even though some values did match the filter condition (see attachment).
Posted on: 04 Jun 2019 08:17
Works perfectly, thank you.
Dess | Tech Support Engineer, Sr.
Posted on: 04 Jun 2019 06:48
Hello, Sasa,

The provided sample project and video are greatly appreciated.

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use the following custom RadListFilterPopup:

Private Sub RadGridView1_FilterPopupRequired(sender As Object, e As Telerik.WinControls.UI.FilterPopupRequiredEventArgs) Handles RadGridView1.FilterPopupRequired
    If e.Column.Name = "Start" Or e.Column.Name = "End" Then
        e.FilterPopup = New MyRadListFilterPopup(e.Column, True)
    End If
End Sub
Public Class MyRadListFilterPopup
Inherits RadListFilterPopup
    Public Sub New(ByVal dataColumn As GridViewDataColumn, ByVal groupedDateValues As Boolean)
        MyBase.New(dataColumn, groupedDateValues)
    End Sub
    Protected Overrides Sub OnButtonOkClick(ByVal e As EventArgs)
        Dim filterOperator As FilterOperator = FilterOperator.IsEqualTo
        Dim listFilterElement As IRadListFilterElement = TryCast(GetType(RadListFilterPopup).GetField("listFilterElement", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic).GetValue(Me), IRadListFilterElement)
        Select Case listFilterElement.SelectedMode
            Case ListFilterSelectedMode.All
                filterOperator = FilterOperator.None
            Case ListFilterSelectedMode.Null
                filterOperator = FilterOperator.IsNull
            Case ListFilterSelectedMode.NotNull
                filterOperator = FilterOperator.IsNotNull
        End Select
        If filterOperator <> FilterOperator.IsEqualTo Then
            Dim compositeFilterDescriptor As CompositeFilterDescriptor = New CompositeFilterDescriptor()
            compositeFilterDescriptor.PropertyName = MyBase.DataColumn.Name
            compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.[Or]
            For Each entry As DictionaryEntry In listFilterElement.SelectedValues
                For Each value As Object In CType(entry.Value, ArrayList)
                    Dim descriptor As FilterDescriptor
                    If TypeOf MyBase.DataColumn Is GridViewDateTimeColumn OrElse MyBase.DataColumn.DataType = GetType(DateTime) OrElse MyBase.DataColumn.DataType = GetType(DateTime?) Then
                        descriptor = New DateFilterDescriptor(MyBase.DataColumn.Name, FilterOperator.IsEqualTo, CType(value, DateTime?), False)
                        descriptor = New FilterDescriptor(MyBase.DataColumn.Name, FilterOperator.IsEqualTo, value)
                    End If
            MyBase.FilterDescriptor = compositeFilterDescriptor
        End If
    End Sub
End Class

I hope this information helps.

Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Attached Files: