Correct way to access property name in ClientTemplate

4 posts, 1 answers
  1. Jaesoon
    Jaesoon avatar
    60 posts
    Member since:
    Oct 2012

    Posted 04 Jun 2015 Link to this post

    I'm trying to add in custom conditions in the ClientTemplate using the guide here http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/faq

    I have a checkbox in the child grid which i want to show a cross or a tick depending on the state.

    ​columns.Bound(o => o.IsChecked).ClientTemplate(
     
        "# if (IsChecked == true) { #" +
            "<i class='tickButton'></i>" +
        "# } else { #" +
            "<i class='crossButton'></i>" +
        "# } #"
    );

     However, doing this, i get the error message "Uncaught ReferenceError: IsChecked is not defined"

     

    What is the correct way to get this columns bound value?

  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 05 Jun 2015 Link to this post

    Hello Jaesoon,

    This is the correct way to bind the column with conditional logic in a template, if the name of the field is IsChecked. A possible reason for the issue could be that the template is used inside a detail Grid, in which case the # symbols which are part of the Kendo UI template syntax should be escaped with double backslash (\\).

    Regards,
    Dimiter Madjarov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Jaesoon
    Jaesoon avatar
    60 posts
    Member since:
    Oct 2012

    Posted 05 Jun 2015 in reply to Dimiter Madjarov Link to this post

    Thanks Dimiter, that's exactly what i needed - putting in double backslashes before every instance of #.

     

    Thanks again for your help.

  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 08 Jun 2015 Link to this post

    Hello Jaesoon,

    Thanks for the update. Have a great week!

    Regards,
    Dimiter Madjarov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top