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

Applying greater/less than than filter when date column value is null

2 Answers 484 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vijay Srinivasan
Top achievements
Rank 1
Vijay Srinivasan asked on 27 Oct 2009, 11:26 AM
Hi,

    We are using "RadControls for Silverlight Q2 2009" to display results in radgridview. We have two date columns, start date and stop date, which are of type "System.Nullable<DateTime>". Some of the values in the stop date are null. When StopDate is null, it is considered to be infinity i.e. current record is valid forever after the start date.

We would want to filter the grid in such a way that current date falls between start date and stop date (StartDate<=Today AND Today<=StopDate). When StopDate is null, expression "Today<=StopDate" is expected to return true. We were able to implement the "StartDate<=Today" by changing the fieldfilterdescriptor.filter1.value and changing the operator to "greater than or equal to" programatically. However we were not able to do this with the "StopDate". When we change the fieldfilterdescriptor.filter1 value to current date, none of the records having the null values in stop date are shown. How do we change the filter functionality in such a way that, when we filter on stop date using "greater than or equal to", all records which have "Stop Date" greater than or equal to the filter value or "Stop Date" as null are disaplyed?

Vijay

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 28 Oct 2009, 08:08 AM
Hi Vijay Srinivasan,

Dates cannot be compared with null outside any specific context. Is a given date more or less than null?

Fortunately, you have a specific context in which you need to compare a date with null. That is why you will need to create two IValueConverters for the two columns. One would return DateTime.MinValue when the incoming value is null and the other will return DateTime.MaxValue. Assign these converters to the DataMemberBindings of the two columns. This should solve the problem.

Regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
JJ
Top achievements
Rank 1
answered on 18 Feb 2011, 10:04 PM
don't under stand what you mean for creating two IValueConverters , can you give an example?

Thanks!
Tags
GridView
Asked by
Vijay Srinivasan
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
JJ
Top achievements
Rank 1
Share this question
or