Grouping Items in a ListView Control

You can group the items that appear in a ListView control. For example, instead of displaying a flat list of products, you can group products by product category (see Figure 8.13).

Image

FIGURE 8.13 Grouping ListView items

If you want to take advantage of groups, then you need to create a grouped data source. You create a grouped data source by calling the WinJS.Binding.List createGrouped() method.

The code in Listing 8.13 and Listing 8.14 illustrates how you can use the createGrouped() method to group products by categories.

LISTING 8.13 Grouping ListView Items (grouped\grouped.html)

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.