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

how to conditionally apply row template

2 Answers 576 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 13 Jun 2013, 02:22 PM
Let's say I have two row templates, normal and urgent, and which template is to be applied to the row will depend on the value in the row's {status} field. How and where would the desired template be applied to the row such that when the user groups the grid, the template will travel with the row?

<script id="urgentRowTemplate" type="text/x-kendo-tmpl">
    <tr class="urgent">
         <td> ${name} </td>
        <td>  ${reasonForCall} </td>
        <td>  ${status} </td>
    </tr>
</script>
 
 <script id="normalRowTemplate" type="text/x-kendo-tmpl">
    <tr class="normal">
         <td> ${name} </td>
        <td>  ${reasonForCall} </td>
        <td>  ${status} </td>
    </tr>
</script>



2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jun 2013, 02:52 PM
Hello,

 The row template can be set to only one value. However you can achieve the desired result using only one template:

<script id="urgentRowTemplate" type="text/x-kendo-tmpl">
    # if (status == "urgent") { #
    <tr class="urgent">
    # } else { #
     <tr class="normal">
    # } #
        <td> ${name} </td>
        <td>  ${reasonForCall} </td>
        <td>  ${status} </td>
    </tr>
</script>

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tim R
Top achievements
Rank 1
answered on 14 Jun 2013, 06:04 PM
Excellent. Thanks
Tags
Grid
Asked by
Tim R
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Tim R
Top achievements
Rank 1
Share this question
or