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

1 Answer 4806 Views
TreeList
Dave
Top achievements
Rank 1
Dave asked on 12 Jan 2016, 07:51 PM

Hello,

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.

Dave

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 14 Jan 2016, 01:12 PM
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#  #}#"

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Dave
Top achievements
Rank 1
commented on 22 Jan 2016, 03:15 PM

Hi Alexander,

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

Dave

Chris
Top achievements
Rank 1
Veteran
Iron
Iron
commented on 05 Jan 2018, 03:49 AM

null to "" (not "null") should handle by component directly, right ? null to "" - handle by programmer is not reasonable in physical implementation.

 

Best regards

 

Chris

 

 

Stefan
Telerik team
commented on 08 Jan 2018, 09:18 AM

Hello, Chris,

Thank you for the feedback.

Could you please advise how would you expect the null values to be shown by the Kendo UI TreeList by default? This will help us discuss the approach and advise if it is applicable in the widget.

Thank you in advance.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
commented on 09 Jan 2018, 02:38 AM

Not only TreeList, I think all components(ex. TextBox,etc.) should default show empty("") while the value is null. 

 

Best regards

 

Chris

 

 

Stefan
Telerik team
commented on 10 Jan 2018, 08:22 AM

Hello, Chris,

For now, displaying null is the default behavior and changing it will cause a breaking change in the widgets.

If the Kendo UI community thinks that displaying empty string by default is a better behavior please submit a feature request in our feedback portal and based on its popularity we may implement it in a future release:

http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback


Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
darryl
Top achievements
Rank 1
commented on 25 Jan 2024, 04:05 PM

6 years later... Its for reasons like this that i stopped subscribing to kendo. very poor decision on a library meant to DISPLAY data to end-user. Then no fix for it as if ANYONE wants "null" to display to end users.  Forcing implementors to add stupid if null to the frontend logic or converting null to empty string in backend is beyond stupid.
Nikolay
Telerik team
commented on 29 Jan 2024, 01:30 PM

Hi Darryl,

Thank you for the feedback.

The solution to this is to use a template for the column that contains null values. Please refer to the first reply in this thread:

Regards,

Nikolay

Tags
TreeList
Asked by
Dave
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or