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

Correct way to access property name in ClientTemplate

3 Answers 403 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaesoon
Top achievements
Rank 1
Jaesoon asked on 04 Jun 2015, 08:36 AM

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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 05 Jun 2015, 06:26 AM

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
0
Jaesoon
Top achievements
Rank 1
answered on 06 Jun 2015, 02:16 AM

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

 

Thanks again for your help.

0
Dimiter Madjarov
Telerik team
answered on 08 Jun 2015, 07:07 AM

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
Tags
Grid
Asked by
Jaesoon
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Jaesoon
Top achievements
Rank 1
Share this question
or