Winjs flipview different items template

373 views Asked by At

I have a simple question: I have a flipview in which I want to display different kinds of items. For example: First item in the flipview will be a listview, the second item - an image, the third - a table..... How can I achieve this? Is there a way I can set differetn item templates for the items in the view?

My first I idea is to make an item template which contains the different items, but when visualized only the correct one will be visible, but I think this is a bit... wrong to do.

2

There are 2 answers

0
Anobik On

Look i dont know but You will also have to put some effort into it :) This is a templating function with different templates for listView and I guess it would be almost similiar ... Like looping through the data source and providing differet templates. I have implemented this in list view. Try Modifying list to flip and set it accordingly. the example is well demonstrated you can go through it and let me know if you need any further clarifications.

Dynamic template winjs listview

:) let me know if u have any trouble understanding it.

0
Kraig Brockschmidt - MSFT On

You're asking how to render a different template based on the item data. You can't do that with a declarative template, so you need to use a template function instead. That way, the function checks the item data and determines how to render that item.

Scenario 6 of Flipview control sample demonstrates how to set up a template function with different kinds of optimizations. I also explain the structure in Chapter 5 of my free ebook, Programming Windows 8 Apps in HTML, CSS, and JavaScript (MSPress). Specifically see "Template Functions (Part 1)" on page 207 of the PDF. I do recommend reading that to understand how the different promises are being used, as the code by itself is not always obvious if you don't have a clear understanding of promises.