Correct way to do if statement in a client template?

I'm trying to put a conditional in a client template and can't figure out where in the docs this is addressed. Could you point me to the correct area? Here's the code that's not working. The conditional is "CanBeOverturned":

Thanks in advance for any help you can provide!

Add a comment

1 Answer , 1 is accepted

Telerik team answered on 05 Feb 2013, 08:40 AM

Hello Scott, There is an if example at the very bottom of this documentation article. Please let us know if you still experience troubles with your implementation. Regards,
Petyo
the Telerik team

Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

Top achievements commented on 13 Aug 2013, 02:46 PM

Hi Petyo,
I'm struggling with the syntax of this conditional statement. I've studied the online documentation but no success.
.ClientFooterTemplate("

Avg: # if(data.TotalSalesAmt.sum == 0) # else #
")

Telerik team commented on 15 Aug 2013, 11:26 AM

Hello, As far as I see, there are some mismatched # symbols in your template. Try breaking the template to multiline string in order to debug it. Regards,
Petyo
Telerik

Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

Top achievements commented on 19 Aug 2013, 04:04 PM

Breaking the statement up into separate lines was a good suggestion. This worked:
.ClientFooterTemplate("# if(data.TotalSalesAmt.sum == 0) " +
"Avg: #= kendo.toString(0,'P2') # #> " +
"else Avg: #= kendo.toString(data.TotalMarginAmt.sum / data.TotalSalesAmt.sum,'P2') # #>#"
)

Top achievements commented on 02 May 2020, 02:04 PM

Hi, Is there a #: (mightbeNull)??(nullAternative) #
I get a fail if i leave of the "#># else This is because I wanted to add in a comma if a additional field had a value eg Address3 is often empty where as Address1 always has the street details. Trying to apply what works in handlebars<> to this where there are hole in the docs :/

Telerik team commented on 05 May 2020, 04:52 PM

Hello Doug, The suggested syntax is not supported in Kendo Templates. Could you please provide an example demonstrating the issues you are experiencing with the regular if-else statements? Maybe I will be able to suggest something to make it work. Looking forward to your reply. Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.

Top achievements commented on 05 Jul 2020, 12:00 PM

Would be nice to see the URL to the complete guide to 'KendoUI Template Syntax' so when you google those 3 key words you end up at https://docs.telerik.com/kendo-ui/framework/templates/overview

Telerik team commented on 07 Jul 2020, 02:40 PM

Hello Doug, Could you please provide some additional information about your last post? Is there a broken link to the Template article? Or is the link not on the top of the Google results when you type the three keywords you mentioned? Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.

Telerik team commented on 16 Aug 2021, 12:23 PM

Hi everyone. It has been reported that the link from the post of Petyo is not working. If someone needs the correct link it can be found here.

Add a comment Answer this question Top achievements Answers by Telerik team Share this question Complete .NET Toolbox Complete JavaScript Toolbox Get Products Recognition Get in touch

Telerik and Kendo UI are part of Progress product portfolio. Progress is the leading provider of application development and digital experience technologies.

Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.

Progress, Telerik, Ipswitch, Chef, Kemp, Flowmon, MarkLogic, Semaphore and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.