Understanding the ListView control
In the previous chapter we introduced a new set of controls provided by the Windows Library for JavaScript; one of these controls was the ListView control, marked as WinJS.UI.ListView
. What this object basically does is displays data items in a customizable list or grid. To create a ListView control, we need to add the data-win-control
property to a div
element and set its property to WinJS.UI.ListView
. In the default.html
page, add the following code inside the body
tag:
<body> <div id="sampleListView" data-win-control="WinJS.UI.ListView"> </div> </body>
This will create an empty ListView. So, if we run the app, there will be nothing to see. Since it is a WinJS
control, it will not be rendered in the markup until after we call the WinJS.UI.processAll
function.
Let's add some data for the sampleListView
control to display. The data that might come from a database from the Web or from a JSON data source, will create a data source...