ListView.selection property

0 out of 7 rated this helpful - Rate this topic

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.

BR211852.wedge(en-us,WIN.10).gifTo determine how the selection changed

  1. 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 lv is a ListView control.)

  2. Register for the onselectionchanged event.
  3. When the onselectionchanged event fires, call selection.getIndices again to get an Array of the currently selected item indexes.
    
    var currentSelection = lv.selection.getIndices();
    
    
  4. 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

Ui.js

See also

ListView

 

 

Build date: 12/5/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.