conditional formatting does not work

5 posts, 0 answers
  1. Shannon
    Shannon avatar
    6 posts
    Member since:
    Oct 2012

    Posted 07 Dec 2012 Link to this post

    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" + "#}#");
  2. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 11 Dec 2012 Link to this post

    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!
  3. Shannon
    Shannon avatar
    6 posts
    Member since:
    Oct 2012

    Posted 12 Dec 2012 Link to this post

    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?
  4. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 13 Dec 2012 Link to this post

    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!
  5. Francois
    Francois avatar
    2 posts
    Member since:
    Aug 2004

    Posted 16 Jan 2013 Link to this post

    Thank you Daniel..
    Had the same issue and lost a few more hair in the process of finding the answer! 
    Worked for me.
Back to Top