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

3 posts, 0 answers
  1. Vijay Srinivasan
    Vijay Srinivasan avatar
    4 posts
    Member since:
    Aug 2009

    Posted 27 Oct 2009 Link to this post


        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?

  2. Rossen Hristov
    Rossen Hristov avatar
    2478 posts

    Posted 28 Oct 2009 Link to this post

    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.

    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.
  3. DevCraft R3 2016 release webinar banner
  4. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 18 Feb 2011 Link to this post

    don't under stand what you mean for creating two IValueConverters , can you give an example?

Back to Top