locked
find selected items in listview

    Question

  • how to find selected items in a listview when I created its template in html

    Wednesday, February 12, 2014 3:14 PM

Answers

  • Hi mayanklohani,

    Have you tried this: ISelection interface. To obtain an ISelection object, call the ListView.selection property. You could also find a sample from the MSDN documentation page.

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by mayanklohani Thursday, February 13, 2014 8:05 AM
    Thursday, February 13, 2014 1:26 AM
    Moderator

All replies

  • Hi mayanklohani,

    Have you tried this: ISelection interface. To obtain an ISelection object, call the ListView.selection property. You could also find a sample from the MSDN documentation page.

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by mayanklohani Thursday, February 13, 2014 8:05 AM
    Thursday, February 13, 2014 1:26 AM
    Moderator
  • I tried it but its not working here's my code                                                                                                                                   

    <div id="retrieved-search-results-template"
             data-win-control="WinJS.Binding.Template"
             style="display: none">
            <div class="container">
                <div class="series-container">
                    <div class="banner">
                        <img src="/images/gray.png" data-win-bind="src:banner ;alt:name" />
                    </div>
                    <div class="overview">
                        <div>
                            <h3 data-win-bind="innerText: overview" />
                        </div>
                    </div>

                    
                </div> 
            </div>
        </div>

    --------------------------------------------------

     <div id="retrieved-search-results" data-win-control="WinJS.UI.ListView"
                 data-win-options="{itemDataSource : RetrievedSeriesData.retrievedSeries.dataSource,
                                    itemTemplate: select('#retrieved-search-results-template'),
                                    layout: {type: WinJS.UI.GridLayout},
                                    tapBehavior:'toggleSelect',
                                   }">
            </div>

    ------------------------------------------------------

    javascript:

    element.querySelector('#retrieved-search-results').addEventListener('iteminvoked', showHideAddSeries, false); //event handler added inside the ready function

    function showHideAddSeries(eventInfo){

    }

    Now in showhideadd series how do i get get the no of selections






    • Edited by mayanklohani Thursday, February 13, 2014 1:56 AM
    Thursday, February 13, 2014 1:51 AM
  • Hi mayanklohani,

    So what is the code inside your showHideAddSeries function?

    If you want to get the selection items in this function, the code could be:

    var lView = element.querySelector("#retrieved-search-results").winControl;
    var itemselected = lView.selection;

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, February 13, 2014 2:01 AM
    Moderator
  • thankyou, its working fine now
    • Edited by mayanklohani Thursday, February 13, 2014 2:42 AM
    Thursday, February 13, 2014 2:42 AM