This is a migrated thread and some comments may be shown as answers.
template and altTemplate
2 Answers 8 Views
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 1
Morten asked on 04 Sep 2018, 11:03 AM

Hi, 

In some of my listviews I'd like to alternate item color and find myself using almost identical templates in the template and altTemplate properties.

template:

<script id="template" type="text/x-kendo-template">
<div class="regular-color">#:value#</div>
</script>

altTemplate

<script id="template-alt" type="text/x-kendo-template">

<div class="alt-color">#:value#</div>

</script>

How can I do this smarter?

Thanks in advance.

/Morten

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 05 Sep 2018, 06:15 AM
Hi Morten,

You can achieve this requirement by setting a common class for this container div element - for instance, class="itemContainer". Then, you can make avail of the even and odd selectors provided by CSS in order to apply different styling:
https://www.w3.org/Style/Examples/007/evenodd.en.html

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Morten
Top achievements
Rank 1
answered on 05 Sep 2018, 09:25 AM

Thanks Eyup, for pointing out such an elegant solution.

Asked by
Morten
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Morten
Top achievements
Rank 1
Share this question
or