template and altTemplate

3 posts, 0 answers
  1. Morten
    Morten avatar
    351 posts
    Member since:
    Jul 2012

    Posted 04 Sep 2018 Link to this post


    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.


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


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

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


    How can I do this smarter?

    Thanks in advance.


  2. Eyup
    Eyup avatar
    4074 posts

    Posted 05 Sep 2018 Link to this post

    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:

    I hope this will prove helpful.

    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.
  3. Morten
    Morten avatar
    351 posts
    Member since:
    Jul 2012

    Posted 05 Sep 2018 in reply to Eyup Link to this post

    Thanks Eyup, for pointing out such an elegant solution.

Back to Top