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

conditional formatting does not work

4 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shannon
Top achievements
Rank 1
Shannon asked on 07 Dec 2012, 05:38 PM
I am trying to conditionally format a column of booleans to display "Yes" if true and "No" if false.  I am following the example here, but it is not working.  Regardless of the values in my "IsEnabled" column, it displays the same thing for every column.  In the case below, it displays "Yes" for every row in the column even though "IsEnabled" is false. Please advise. Thanks.

columns.Bound(n => n.IsEnabled)
             .Width(100)
             .ClientTemplate(
                "# if (IsEnabled) { #" + "Yes" +
                "# } else { #" + "No" + "#}#");

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Dec 2012, 03:08 PM
Hello Shannon,

The code looks correct. I attached a small sample project which shows "Yes" or "No" depending on the field value. What is the difference in your case?

Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shannon
Top achievements
Rank 1
answered on 12 Dec 2012, 02:16 PM
Daniel,
Thanks for the response.  It seems the problem is because I am trying to do it in the template for a sub-grid of a grid hierarchy. The code works fine when used on the outer grid.  But when I apply to the Client Template every column is rendered the same way.  For example, if the value in the first row is false, then it and every other row will display "No" even if there are some true values in those rows.  Any ideas?
0
Daniel
Telerik team
answered on 13 Dec 2012, 06:35 PM
Hello Shannon,

The "#" characters needs to be escaped when used in a client template of a detail Grid. Otherwise the code will not be evaluated in the correct context. I attached the project modified to show the syntax in the detail.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Francois
Top achievements
Rank 1
answered on 16 Jan 2013, 10:59 PM
Thank you Daniel..
Had the same issue and lost a few more hair in the process of finding the answer! 
Worked for me.
Tags
Grid
Asked by
Shannon
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shannon
Top achievements
Rank 1
Francois
Top achievements
Rank 1
Share this question
or