This is a migrated thread and some comments may be shown as answers.

Change template?

1 Answer 90 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
JohnVS
Top achievements
Rank 1
JohnVS asked on 03 Oct 2014, 07:09 PM
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?

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 07 Oct 2014, 08:56 AM
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.  

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
MVVM
Asked by
JohnVS
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or