if statement in clienttemplate not working

3 posts, 1 answers
  1. sjarl
    sjarl avatar
    10 posts
    Member since:
    Dec 2010

    Posted 16 Mar 2018 Link to this post


    In my clientTemplate I try to do the following:

    "<div style=\"display:#if(MimeType == 'application/pdf') {#block#} else {#none#}# \">" +

    But when I compare to string it keept giving me an error
    "Error: Invalid template:'"

    and I treid a lot if different ways to do this.

    If I compare to a boolean or integer it goes ok, but for some reason I can't get string compare to work.

    Can someone help me out?

    thank you.




  2. Answer
    Alex Hajigeorgieva
    Alex Hajigeorgieva avatar
    1054 posts

    Posted 19 Mar 2018 Link to this post


    Thank you for the provided code snippet. I used it to attempt to get the same error as you have, however to no avail:

    .Columns(columns =>
     columns.Bound(p => p.ShipName).ClientTemplate("<div style=\"display:#if(MimeType  == 'application/pdf') {#block#} else {#none#}# \">Test</div>");

    Here is the resulting HTML:

    Something you can try is to pass a JavaScript function instead:


    If this does not help, please provide additional information - the model and grid declarations as well as a sample data item from the response so I can test with your scenario specifics. Look forward to your response.

    Kind Regards,
    Alex Hajigeorgieva
    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.
  3. sjarl
    sjarl avatar
    10 posts
    Member since:
    Dec 2010

    Posted 19 Mar 2018 in reply to Alex Hajigeorgieva Link to this post

    Hello Alex,
    the Javascript approach works for now.

    thank you.

Back to Top