WinJS.UI.computeDataSourceGroups function

Returns a new IListDataSource that adds group information to the items of another IListDataSource.

Syntax

var iListDataSource = WinJS.UI.computeDataSourceGroups(listDataSource, groupKey, groupData, options);

Parameters

  • listDataSource
    Type: IListDataSource**

    The data source for the individual items to group.

  • groupKey
    Type: Function

    A callback function that accepts a single argument: an item in the IListDataSource. The function is called for each item in the list and must return the group key for that item as a string.

  • groupData
    Type: Function

    A callback function that accepts a single argument: an item in the IListDataSource. The function is called on one IListDataSource item for each group and must return an object that represents the header of that group.

  • options [optional]
    Type: Object

    An object that can contain properties that specify additional options:

    • groupCountEstimate
      A Number value that is the initial estimate for the initial number of groups. If -1 is specified, no result will be returned until the actual number of groups has been determined.

    • batchSize
      A Number greater than 0 that specifies the number of items to be fetched during each processing pass when searching for groups. In addition to the number specified, one item from the previous batch will always be included.

Return value

Type: IListDataSource**

An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.

Requirements

Minimum WinJS version

WinJS 3.0

Namespace

WinJS.UI