How to change the selection mode (HTML)

Applies to Windows and Windows Phone

The ListView control's selectionMode property specifies how the user can select items in the list.

What you need to know

Technologies

Prerequisites

Instructions

Change the selection mode

The selectionMode property supports these values, as defined by the SelectionMode enumeration:

TermDescription

none

Items cannot be selected.

single

Only one item may be selected. Clicking an item changes the selection to that item.

multi

Multiple items may be selected. Clicking additional items adds them to the selection.

 

To specify the selection mode in HTML, use the data-win-options attribute to set the selectionMode to a string representation of one of the allowed enumeration values, such as "none" or "single".

Hh465449.wedge(en-us,WIN.10).gifTo specify the selection mode in HTML

  • This example sets the selection mode so that only a single item can be selected.

    
    <div id="basicListView" 
        data-win-control="WinJS.UI.ListView"
        data-win-options="{ itemDataSource : DataExample.itemList.dataSource, itemTemplate: select('#mediumListIconTextTemplate'), selectionMode: 'single'}">
    </div> 
    
    

To specify the selection mode in JavaScript, retrieve the control and set its selectionMode property.

Hh465449.wedge(en-us,WIN.10).gifTo specify the selection mode in JavaScript

  • The next example sets the selection mode so that only a single item can be selected.

    
    var myListView = document.getElementById("basicListView1").winControl;
    myListView.selectionMode = WinJS.UI.SelectionMode.single;
    
    

Related topics

Quickstart: Adding a ListView

 

 

Show:
© 2014 Microsoft