Note that there are some explanatory texts on larger screens.

plurals
  1. POTelerik grid custom formatting changing displayed text colour If "Yes" green If "No" Red
    primarykey
    data
    text
    <p>I have a simple grid which I want 4 columns to have set that if "Yes" is displayed then it's in green and if "No" is displayed then it's in red, these are the only 2 values which those columns can display</p> <pre><code>c.Bound(x =&gt; x.col1); c.Bound(x =&gt; x.col2) .Title("col2 example"); c.Bound(x =&gt; x.col3) .Title("col3 example"); c.Bound(x =&gt; x.col4) .Title("col4 example"); c.Bound(x =&gt; x.col5) .Title("col5 example"); </code></pre> <p>col2-5 are the ones in question</p> <pre><code> col1 = x.col1, col2 = (x.col2Id.HasValue) ? "Yes" : "No", col3 = (x.col3Id.HasValue) ? "Yes" : "No", col4 = (x.col4Id.HasValue) ? "Yes" : "No", col5 = (x.col5) ? "Yes" : "No" </code></pre> <p>ofc all the col... have different names but this way it's anon.</p> <p>Edit - Tried the code in my latest project to find, client template = would always only display in those fields "Yes" in green, server template = would now display in the fields <code>&lt;span style='color:green'&gt;Yes&lt;/span&gt;</code> if the field was meant to display yes and <code>&lt;span style='color:red'&gt;No&lt;/span&gt;</code> if the field was meant to display no. so both bits of codes half work and the only difference between me using them then and now is that I'm now using mvc3.</p> <p>Edit 2 - In whether it's a change with the latest version of telerik or something else I don't know but the issue was resolved if I changed the client template code to be like below.</p> <pre><code>.ClientTemplate("&lt;# if(Col2 == 'Yes') { #&gt;&lt;span style='color:green'&gt;Yes&lt;/span&gt;&lt;# } else { #&gt;&lt;span style='color:red'&gt;No&lt;/span&gt;&lt;# } #&gt;") </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload