Gets an ISelection that contains the range of currently selected items.
Syntax
var selection = listView.selection;
Property value
Type: ISelection
An ISelection object containing the selected items.
Remarks
Determining the difference when the selection changes
The onselectionchanged event notifies you when the ListView control's selection changes, but it doesn't tell you how the selection changed.
To determine how the selection changed
- Before the selection changes, cache the current selection by calling selection.getIndices and storing the result. selection.getIndices returns an Array that contains the indexes of the currently selected items.
var prevSelection = lv.selection.getIndices();(Where
lvis a ListView control.) - Register for the onselectionchanged event.
- When the onselectionchanged event fires, call selection.getIndices again to get an Array of the currently selected item indexes.
var currentSelection = lv.selection.getIndices(); - Compare the two arrays. One way to calculate the difference is to use the Array.filter method.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS.UI |
|
Library |
|
See also
Build date: 12/5/2012