13
votes

I need to apply a condition in my kendo grid column template.

Here is my code:

columns: [
{
    field: "EmpName",
    title: "Name",
    template: '<a href="\\#" onclick="showName();">#= if (empName == null){ "show xxx"
               } else {
                   // I want to show actual name if it is not null
                   empName
               } #</a>'
},
3

3 Answers

19
votes

Check this

'<a href="" onclick="showName();">'# if( empName==null) {#<span>show xxx<span># } else {#<span>#: empName#<span>#} #'</a>'
4
votes

something like this should work for you:

# if(test == null) { #
    <span style="border:1px solid red"></span>
# } else { #
    <span style="border:1px solid lime"></span>
# } #

Don“t know how to do inline at the moment.

2
votes

Hope it will also help

<script type="text/x-kendo-template" id="template">
    <div id="details-container">
       <dt> Name:</dt> #= Name #
      <br>  
       <dt>Selected Device: </dt>  iOS:-# if (PushToiOS == true) { #Yes# } else { #No# } #,
                                   Android:-# if (PushToAndroid == true) { #Yes# } else { #No# } #,
                                   WP:-# if (PushToWP == true) { #Yes# } else { #No# } #
      <br>
       <dt>Expire Date:</dt> #= kendo.toString(ExpiredDate, "MM/dd/yyyy") #
      <br>
    </div>
</script>