Completed
Last Updated: 28 Jun 2019 08:50 by ADMIN
Release R2 2019 SP1
Sasa
Created on: 03 Jun 2019 14:22
Category: GridView
Type: Bug Report
1
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).
2 comments
Sasa
Posted on: 04 Jun 2019 08:17
Works perfectly, thank you.
ADMIN
Dess | Tech Support Engineer, Principal
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
            SetFilterOperator(filterOperator)
            Me.ClosePopup(RadPopupCloseReason.CloseCalled)
        Else
            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)
                    Else
                        descriptor = New FilterDescriptor(MyBase.DataColumn.Name, FilterOperator.IsEqualTo, value)
                    End If
 
                    compositeFilterDescriptor.FilterDescriptors.Add(descriptor)
                Next
            Next
 
            MyBase.FilterDescriptor = compositeFilterDescriptor
            OnFilterConfirmed()
        End If
    End Sub
End Class

I hope this information helps.

Regards,
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: