locked
How to pre select item in listView added with Blend into HTML/Javascript project

    Question

  • So I added the listView into my Visual Studio 2012 HTML/Javascript project using the Blend and bind with my data that data shows in listView as different items. Now I want to pre select the item (items) in listView on program load as well as on button click event. How can I get the selection property using Javascript code?
    Monday, January 7, 2013 6:31 PM

Answers

  • Hi,

    You can use the follow code in the button click event:

            var listview = document.getElementById("basicListView").winControl;
            //select the items
            listview.selection.set([2,3,4]);


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by markoamer Wednesday, January 9, 2013 6:45 PM
    Tuesday, January 8, 2013 8:10 AM

All replies

  • Hi,

    You can use the follow code in the button click event:

            var listview = document.getElementById("basicListView").winControl;
            //select the items
            listview.selection.set([2,3,4]);


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by markoamer Wednesday, January 9, 2013 6:45 PM
    Tuesday, January 8, 2013 8:10 AM
  • Great. Thank you very much
    Wednesday, January 9, 2013 6:49 PM