This is a migrated thread and some comments may be shown as answers.

Templo

2 Answers 125 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Alon
Top achievements
Rank 1
Veteran
Alon asked on 01 Mar 2019, 01:00 PM

I have the following template defined

<script type="text/x-kendo-tmpl" id="tmplterminalSummary">
<div class="row grandTotalRow"><br>
<span class="col-md-1 col-xs-3 resultLabel text-left">Gift Cards Terminal</span><br>
<span class="col-md-2 col-xs-2 resultValue">#:kendo.toString(gcardGross,"c")#</span><br>       
<span class="col-md-3 col-xs-2 resultValue">#:kendo.toString(gcardRefund,"c")#</span><br>       
<span class="col-md-3 col-xs-2 resultValue">N/A</span><br>       
<span class="col-md-3 col-xs-2 resultValue">#:kendo.toString(netGCard,"c")#</span><br>   
</div>
</script>

 

The issue I am having is that sometimes gcardGross is undefined. This results in a run time error like this https://screencast.com/t/6lHLtsliMx5F

I have tried replacing it with a line like this but unfortunately the error continues to occur. 

<span class="col-md-2 col-xs-2 resultValue">#:gcardGross?kendo.toString(gcardGross,"c"):kendo.toString(0,"c")#</span><br> 

So how can I define a default value so that 0 is shown if the property is undefined.

 

 

2 Answers, 1 is accepted

Sort by
0
Alon
Top achievements
Rank 1
Veteran
answered on 01 Mar 2019, 01:10 PM

I should also add that I also tried this but I still get the same error

 

<div class="row grandTotalRow">
<span class="col-md-1 col-xs-3 resultLabel text-left">Gift Cards Terminal</span>
#if (gcardGross){#
<span class="col-md-2 col-xs-2 resultValue">#:kendo.toString(gcardGross,"c")#</span>
#} else {#
<span class="col-md-2 col-xs-2 resultValue">#:kendo.toString(0,"c")#</span>
#}#
<span class="col-md-3 col-xs-2 resultValue">#:kendo.toString(gcardRefund,"c")#</span>
<span class="col-md-3 col-xs-2 resultValue">N/A</span>
<span class="col-md-3 col-xs-2 resultValue">#:kendo.toString(netGCard,"c")#</span>
</div>

0
Alon
Top achievements
Rank 1
Veteran
answered on 01 Mar 2019, 01:44 PM

OK I figured it out. The following works fine

 

<div class="row grandTotalRow">
<span class="col-md-1 col-xs-3 resultLabel text-left">Gift Cards Terminal</span>
<span class="col-md-2 col-xs-2 resultValue">#:data.gcardGross?kendo.toString(data.gcardGross,"c"):kendo.toString(0,"c")#</span>
<span class="col-md-2 col-xs-2 resultValue">#:data.gcardRefund?kendo.toString(data.gcardRefund,"c"):kendo.toString(0,"c")#</span>
<span class="col-md-3 col-xs-2 resultValue">N/A</span>
<span class="col-md-2 col-xs-2 resultValue">#:data.netGCard?kendo.toString(data.netGCard,"c"):kendo.toString(0,"c")#</span>
</div>

Tags
Templates
Asked by
Alon
Top achievements
Rank 1
Veteran
Answers by
Alon
Top achievements
Rank 1
Veteran
Share this question
or