template and altTemplate

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

    Posted 04 Sep Link to this post

    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. Eyup
    Admin
    Eyup avatar
    3567 posts

    Posted 05 Sep 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:
    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.
  3. Morten
    Morten avatar
    334 posts
    Member since:
    Jul 2012

    Posted 05 Sep in reply to Eyup Link to this post

    Thanks Eyup, for pointing out such an elegant solution.

Back to Top