Creating the Data Source Class

The easiest way to create a custom data source is to derive a new class from the base VirtualizedDataSource class. For example, you can use the following code to create a new data source named MyDataSource:

var MyDataSource = WinJS.Class.derive(    WinJS.UI.VirtualizedDataSource,    // Constructor    function () {        this._adapter = new MyDataAdapter();        this._baseDataSourceConstructor(this._adapter);    });

In the preceding code, two arguments are passed to the WinJS.Class.derive() method to create the new MyDataSource class: a base class (WinJS.UI.VirtualizedDataSource) and a constructor for the new class.

In the constructor for your derived VirtualizedDataSource class, ...

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.