I have a KendoUI grid bound to ko vm
Due to specific requirements (icons in some columns, links , etc) I need to define the rowTemplate, which I define as ko template.
But I want also to have normal and alternate rows in different bg colors.
Because of this I defined two identical templates as below
<script id="rowTmpl" type="text/html">
<tr role="row" >
<td align="center">
<a data-bind="attr: { href: 'scrccc_checkEdit.aspx?id=' + CheckID }" >
<img src="images/icon-edit.gif" border="0" alt="Edit/View Check" />
</a>
</td>
<td data-bind="text: CheckNumber"></td>
....
</tr>
</script>
<script id="altTmpl" type="text/html">
<tr class="k-alt" role="row">
<td align="center">
<a data-bind="attr: { href: 'scrccc_checkEdit.aspx?id=' + CheckID }" >
<img src="images/icon-edit.gif" border="0" alt="Edit/View Check" />
</a>
</td>
<td data-bind="text: CheckNumber"></td>
....
</tr>
</script>
Basically the two templates are identical, except the alt template have class class="k-alt" applied to table row.
But this approach is very bad, because it duplicates the whole markup for row template.
What is a better way to accomplish what I need?
Thank you
if u only want to change the style of alternative row, you can see sample here: http://jsfiddle.net/P5EQt/
HTML
Javascript
CSS
Using the knockout css binding with the condition of id (in my sample) that differentiate the alternative row