0
votes

How to write javascript inside kendo grid row template?

Here is my sample code

<script id="rowTemplate" type="text/x-kendo-tmpl">
    <div>
       <dl>
        <dt>
         <label class="iconPlace"><i class="fas fa-plane"></i></label>
         <label class="iconPlace"><i class="fas fa-building"></i></label>                                     
         <label class="Info"> #:traineeId# (#:traineeName#) </label>
         <label class="rank">#:rank#</label>
        </dt>
       </dl>
    </div>
</script>

I want like this

<script id="rowTemplate" type="text/x-kendo-tmpl">
    <div>
       <dl>
        <dt>
         // if(condition) then
         <label class="iconPlace"><i class="fas fa-plane"></i></label>
         // end condition
         <label class="iconPlace"><i class="fas fa-building"></i></label>                                     
         <label class="Info"> #:traineeId# (#:traineeName#) </label>
         <label class="rank">#:rank#</label>
        </dt>
       </dl>
    </div>
</script>

I applied javascript condition start and end with #, but not working

1

1 Answers

2
votes

Use this:

<script id="rowTemplate" type="text/x-kendo-tmpl">
    <div>
       <dl>
        <dt>
         # if (condition) { #
         <label class="iconPlace"><i class="fas fa-plane"></i></label>
         # } #
         <label class="iconPlace"><i class="fas fa-building"></i></label>                                     
         <label class="Info"> #:traineeId# (#:traineeName#) </label>
         <label class="rank">#:rank#</label>
        </dt>
       </dl>
    </div>
</script>