Change template?

2 posts, 0 answers
  1. JohnVS
    JohnVS avatar
    90 posts
    Member since:
    Apr 2013

    Posted 03 Oct 2014 Link to this post

    Let's say I have a DataSource of products. By default, we display the products in a list form, and that template is called "list-template". 

    <tbody data-template="list-template" data-bind="source: products"></tbody>

    What if we want to allow the user to see the same products but in grid form (e.g. "grid-template")? Can we change the data-template after the fact to do this?
  2. Petyo
    Petyo avatar
    2444 posts

    Posted 07 Oct 2014 Link to this post

    Hello John,

    changing the template reference is not supported for a given element. You may however use if/else constructs in the template based on a global flag, change that flag and re-render the element to achieve something similar.

    Alternatively, you may have two elements bound to the same source and show/hide one of them.  

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top