Null value in date field: "null" appears, I want to show empty or custom text

3 posts, 0 answers
  1. Dave
    Dave avatar
    10 posts
    Member since:
    Nov 2015

    Posted 12 Jan 2016 Link to this post


    I have a TreeList with a nullable date field to be displayed.  The following line adds the field to my Treelist:

        columns.Add().Field(e => e.LastUsed).Format("{0:MMMM d, yyyy}"); 

    If the date field has a value, then the date is displayed.  If it is null, the word "null" is displayed.  I would like to be able to display either a custom text string like "N/A" or a blank, instead of the word "null".

    I also don't want to convert the Treelist to all javascript. 

    Thank you very much for your assistance.


  2. Alexander Popov
    Alexander Popov avatar
    1434 posts

    Posted 14 Jan 2016 Link to this post

    Hi Dave,

    This can be done using a column template that checks the value and renders different text accordingly. For example: 
    "#if(myField === null){# N/A #}else{# #=myField#  #}#"

    Alexander Popov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Dave
    Dave avatar
    10 posts
    Member since:
    Nov 2015

    Posted 22 Jan 2016 in reply to Alexander Popov Link to this post

    Hi Alexander,

    Sorry for the delay in replying back to you.  Thanks for providing a solution.  I appreciate it.  Have a nice day...


Back to Top