Conditional Formatting with a Null DateTime field

7 posts, 1 answers
  1. Pawz
    Pawz avatar
    51 posts
    Member since:
    Aug 2007

    Posted 23 Jun 2008 Link to this post

    What's the best way to add conditional formatting for a datetime field that may be null?

    I wanted to highlight all records that had a date in the past, for records that actually *have* a date. How do I do this?
  2. Answer
    Milen
    Admin
    Milen avatar
    163 posts

    Posted 24 Jun 2008 Link to this post

    Hello Pawz,

    It is a little difficult to workout the appropriate expression, since the comparison operators do not allow comparison with Null or DBNull value. This area needs improvement, and will be improved in the future versions.

    However, here is the rule that fits to your requirement:

    - For Expression of the rule pass =IsNull(Fields.DateField, "9999-12-31")
    This way if the field has Null value, it will be replaced with the max DateTime value.

    - For Operator choose   <   (LessThan)

    - For Value pass =Now()
    to compare the value of the Expression with the current date.

    Hope this information helps.

    Sincerely yours,
    Milen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft banner
  4. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 27 Aug 2010 Link to this post

    Hello Milen,

    i got this Error "An error has occurred while processing TextBox 'textBox3': Cannot perform '='  " when i use following expression for handling DBnull / Null value in Report.

    1)
    Expression ->  = IsNull(Fields.Saturday, "True")   
    Operator ->      =
    Value ->          = True

    2)
    Expression ->  =IIF(Fields.Saturday= "Test",True,IsNull(Fields.Saturday,True)) 
    Operator ->      =
    Value ->          = True

    i want to set background color in TextBox when Fields.Saturday.value is DBNull or "Test".

    how can i do this ?
  5. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 01 Sep 2010 Link to this post

    Hello jayesh goyani,

    The formatting rule you've wrote is trying to compare values from different types. To avoid this our suggestion is to omit the equal operator from the value's expression. By omitting the equal sign the value will be interpreted as a string literal and the comparison will be valid as shown in the following formatting rules:
     Expression Operator   Value
     =IsNull(Fields.Saturday, "True")
     =  True
     =IIF(Fields.Manufacturer = "Test",True,IsNull(Fields.Manufacturer,True))  =  True

    All the best,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 03 Sep 2010 Link to this post

    hi Peter ,

    thanks for your help

    by this expression i m able to set Background image with conditional formatting but it not display record.

    Expression : = Fields.Saturday
    Conditional formatting : =IIF(Fields.Saturday = "Test",True,IsNull(Fields.Saturday,True))        =      True

    See below (attach file) image.
    1. error.jpg
    2. data-sample.png (in below post)
  7. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 06 Sep 2010 Link to this post

    sample file with record.
  8. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 07 Sep 2010 Link to this post

    Hi jayesh goyani,

    The suggested expressions work as expected locally. This leads us to think that the issue could be in the returned data itself. For further assistance we will appreciate if you open a support ticket and send us a sample runnable report with some dummy data that exhibits the erroneous behavior this way we can debug it locally.  

    All the best,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner