I have a simple Kendo ListView with an applied client template. If the data in the row item to which the template is applied happens to be null, then the text 'null' appears by default. How can I change this behavior without having to do ${ ShipToName == null ? '' : ShipToName } every time? I am using a template that has to display numerous bound data items, and having to check for null on each and every one of them is tedious and results in code bloat. Even more importantly (and possibly a second question), I need to be able to evaluate the data value from within one of the Razor MVC HTML wrappers, and am constantly getting an 'Invalid template' exception. Please help!
Example #1:
<script type="text/x-kendo-tmpl" id="editTemplate">
//This is always 'null' by default
#=ShipToName#
//This correctly displays null values as empty string
${ ShipToName == null ? '' : ShipToName }
</script>
Example #2:
<script type="text/x-kendo-tmpl" id="editTemplate">
//This works, but always displays 'null' as the value in the textbox
@Html.TextBox("ShipToName", "#=ShipToName#")
//This causes an 'Invalid template' error
@Html.TextBox("ShipToName", "#if (ShipToName != null) {# #=''# #} else {# #=ShipToName# #}#")
</script>
Example #1:
<script type="text/x-kendo-tmpl" id="editTemplate">
//This is always 'null' by default
#=ShipToName#
//This correctly displays null values as empty string
${ ShipToName == null ? '' : ShipToName }
</script>
Example #2:
<script type="text/x-kendo-tmpl" id="editTemplate">
//This works, but always displays 'null' as the value in the textbox
@Html.TextBox("ShipToName", "#=ShipToName#")
//This causes an 'Invalid template' error
@Html.TextBox("ShipToName", "#if (ShipToName != null) {# #=''# #} else {# #=ShipToName# #}#")
</script>