This is a migrated thread and some comments may be shown as answers.

Filtering on Date Only

5 Answers 410 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 09 Feb 2015, 08:32 PM
I've read the documentation that explains how to filter on the Date value only from here:
http://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/how-to/howto-filter-date-value

But my grid is using auto-generated columns. How do I get this work when I'm not declaring each individual column?

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 10 Feb 2015, 12:06 PM
Hi,

As your columns are auto generated, you could subscribe for RadGridView's AutoGeneratingColumn event and apply any additional setting needed.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rayne
Top achievements
Rank 1
answered on 10 Feb 2015, 01:55 PM
I'm already subscribed to that event for some other stuff.

I even have a check for the col data type so that dates are formatted to display the date only. But I'm unsure how to get the FieldName.Date into the FilterMemberPath so that it filters on Date only.
0
Dimitrina
Telerik team
answered on 12 Feb 2015, 08:51 AM
Hi,

You need to set the FilterMemberPath similarly to how you do so in xaml. Does it not work for you?

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rayne
Top achievements
Rank 1
answered on 12 Feb 2015, 07:46 PM
No. I haven't gotten it to work. I'm a bit stuck on how to identify the correct piece of data so that I can assign it to FilterMemberPath.

Here is a sample of my code, which is located in the AutoGeneratingColumn event handler:

var col = e.Column as GridViewDataColumn;
if (col.DataType == typeof(decimal?))
     col.DataFormatString = "{0:F4}";
else if (col.DataType == typeof (DateTime))
{
    col.DataFormatString = "{0:d}";
    //add code here to filter on Date portion of DateTime
}
0
Dimitrina
Telerik team
answered on 13 Feb 2015, 09:21 AM
Hi,

You can set the FilterMemberPath based on the corresponding DataMemberBinding path.
For example, having your existing code you should add a line like:
col.FilterMemberPath = col.DataMemberBinding.Path.Path + ".Date";


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Ghefar
Top achievements
Rank 1
commented on 21 Mar 2025, 01:10 PM

I have similar situation. My problem is that not all cells have a date value (it can be null/dbnull). 

Using col.DataMemberBinding.Path.Path + ".Date" worked for me only partially, that is only if all cells have a value.  
Any suggestions please?

Stenly
Telerik team
commented on 24 Mar 2025, 03:02 PM

Hello Ghefar,

I provided an answer to the ticket that you opened regarding this case.

Generally, the FilterMemberPath property is the way to go when a property's value, different from the one set to the DataMemberBinding, is needed for the filtering operations. Since the underlying type is a nullable DateTime, the FilterMemberPath property should look as follows when the columns are auto-generated:

private void RadGridView_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
{
    //The current e.Column is bound to a nullable DateTime
    GridViewDataColumn column = (GridViewDataColumn)e.Column;
    //The FilterMemberPath property should be set to "property name + .Value.Date"
    column.FilterMemberPath = column.DataMemberBinding.Path.Path + ".Value.Date";
}

When the column is manually defined, you could set it as follows:

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

With this being said, I hope the provided information will be of help to you.

Tags
GridView
Asked by
Rayne
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or