ISelection.add method

Adds one or more items to the selection.

Syntax

iSelection.add(items).done( /* Your success and error handlers */ );

Parameters

  • items
    Type: Object

    The indexes or keys of the items to add. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section.

Return value

Type: Promise**

A Promise that is fulfilled when the operation completes.

Remarks

The items parameter can be an index, a key, or a range of indexes, or an array that contains one or more of these objects.

  • An index: a numeric index value (Number)

    The add method adds the item at the specified index (the value of items) to the selection.

  • An index: an object that contains an index property that contains a Number

    The add method adds the item at the specified index (the value of items.index) to the selection.

  • A key: an object that contains a key property

    If the itemDataSource supports keys, the add method adds the item that has the specified key (the value of items.key) to the selection.

  • A range of indexes or keys: an object that implements ISelectionRange

    • If the object contains firstKey and lastKey values, the add method adds the items in the specified range to the selection, starting with the item at firstKey and ending with the item at lastKey.

    • If the object contains firstIndex and lastIndex values, the add method adds the items in the specified index range to the selection, starting with the item at firstIndex and ending with the item at lastIndex.

    • If the object contains both index and key values, the add method uses the key values.

Requirements

Minimum WinJS version

WinJS 3.0

Namespace

WinJS.UI

See also

ISelection

ListView.selection