locked
some bug when remove item in a semantic Zoom ListView RRS feed

  • Question

  • I creat a SemanticZoom in my grouped list view like this:

    <div id="semanticZoomDiv" data-win-control="WinJS.UI.SemanticZoom">   
                    
                <div id="listView2a"
                    data-win-control="WinJS.UI.ListView" 
                    data-win-options="{ itemDataSource: myData.groupedList.dataSource, itemTemplate: mediumListIconTextTemplate, groupHeaderTemplate: headerTemplate, groupDataSource: myData.groupedList.groups.dataSource, selectionMode: 'multi', tapBehavior: 'none', swipeBehavior: 'none' }"
                ></div>
    
                <div id="listView2b"
                    data-win-control="WinJS.UI.ListView"
                    data-win-options="{ itemDataSource: myData.groupedList.groups.dataSource, itemTemplate: semanticZoomTemplate, selectionMode: 'none', tapBehavior: 'invoke', swipeBehavior: 'none' }"
                ></div>
    
            </div>

    then I add a Delete command in AppBar for delete some item in listview:

    <div id="appbar" data-win-control="WinJS.UI.AppBar" data-win-options="{sticky:'true'}">
            <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'DeleteCommand',section:'selection', label:'Delete', icon:'delete'}"></button>
        </div>

    In Javascript:

    document.querySelector("#DeleteNotesCommand").addEventListener("click", doClickDeleteNotes, false);
    
    function doClickDeleteNotes() {
        var listView = document.querySelector("#listView2a").winControl;
        var selectionCount = listView.selection.count();
        if (selectionCount > 0) {
            listView.selection.getItems().then(function (items) {
    
                for (var j = items.length - 1; j >= 0; j--) {
                    myData.groupedList.splice(items[j].index, 1);
                }
    
            });
        }
    }

    Then run the app.

    when I select two or more  item in frist group , then click delete, some thing is wrong


    when continue app , the app crash.

    but if I don’t use the SemanticZoom view,just a group listview. all thing is ok.

    so i think this is a WinJS API bug?

    Monday, April 23, 2012 3:55 AM

Answers

  • Thank you!  I was able to repro this and have filed a bug.  I am looking for a workaround for you currently.  The only thing I can think of is disconnecting the datasource, making changes to the list and re-attaching. 

    update:

    I could not find a good workaround.  I think your only workaround will be for you to find out what is selected and then disconnect the datasource, delete these items and reconnect the datasource.


    Jeff Sanders (MSFT)



    Wednesday, April 25, 2012 2:03 PM
    Moderator

All replies