New to Telerik UI for WPF? Download free 30-day trial

Filter on Date and Time

By default, when a GridViewDataColumn is bound to a property of type DateTime the generated field filter editor is a RadDateTimePicker. It's InputMode, however, is DatePicker which means that only the Date portion of the DateTime object can be selected through the UI.

Most probably, however, your DateTime data contains a time part which is different than 00:00:00. When you filter and select a DateTime value, this selected DateTime will have its time part equal to zero. Since DateTime objects with different time parts are not equal for the .NET Framework, you will have no match.

A possible approach in the case when you also wish to filter out the Time portion is to handle the FieldFilterEditorCreated event and set the InputMode of the RadDateTimePicker editor to DateTimePicker. Example 1 demonstrates how this can be achieved.

Example 1: Change the InputMode of the RadDateTimePicker filter editor to DateTimePicker

private void GridView_FieldFilterEditorCreated(object sender, Telerik.Windows.Controls.GridView.EditorCreatedEventArgs e) 
{ 
    if (e.Column.UniqueName == "HireDate") 
    { 
        Telerik.Windows.Controls.RadDateTimePicker picker = e.Editor as Telerik.Windows.Controls.RadDateTimePicker; 
        if (picker != null) 
        { 
            picker.InputMode = Telerik.Windows.Controls.InputMode.DateTimePicker; 
        } 
    } 
} 
Another approach, if you want to filter only on the Date portion of the DateTime objects would be to bind your column directly to the Date (or Year) property of the DateTime object.

Example 2: Bind the column to the Date portion of the property

<telerik:GridViewDataColumn DataMemberBinding="{Binding HireDate.Date}" /> 
As an alternative solution, you can benefit from the FilterMemberPath property of the column. You can use it to filter the column on a property different from the one it displays in its cells.

Example 3: Filter only on the Date portion of the property with FilterMemberPath

<telerik:GridViewDataColumn DataMemberBinding="{Binding HireDate}" FilterMemberPath="HireDate.Date" /> 

See Also

In this article