Best Practices for Editing WinJs.UI.ListView item groupings RRS feed

  • Question

  • I have a WinJS.UI.ListView with groupings in gridview mode that is backed by a WinJS.Binding.List as the data source.  Each item in the data source (dataList) has a "groupName" property that I'm using for grouping.

    I'm using the following piece of code to change the category of one item in order to move it to another group:

    newGroupName = "Week";
    var x = dataList.getAt(0);
    x.groupName = newGroupName;
    dataList.setAt(0, x);

    However, whenever I do that, I get the following exception:

    Exception is about to be caught by JavaScript library code at line 20908, column 5 in ms-appx://microsoft.winjs.1.0/js/ui.js

    0x800a138f - JavaScript runtime error: Unable to get property 'id' of undefined or null reference

    Which seems to be coming from the following method:

    function setFlow(from, to) {
        WinJS.UI._setAttribute(from, "aria-flowto", to.id);
        WinJS.UI._setAttribute(to, "x-ms-aria-flowfrom", from.id);

    What am I doing wrong?  What is the "right" way for me to change the grouping of an item in my list view?


    Sunday, January 13, 2013 4:02 AM

All replies

  • Hi,

    Based on the code above, I think the code has some problem. Could you post more related code? So I will reproduce your scenario on my side.

    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.

    Tuesday, January 15, 2013 7:28 AM
  • Hello,

    I have encountered the same error "Unable to get property 'id' of undefined or null reference" in the setFlow function in ui.js. After several test and debugging the error occurs because I used the createGrouped function with a groupSorter function like this : 

    var list = new WinJS.Binding.List(result);
    var groupedList = list.createGrouped(getGroupKey, getGroupData, compareGroups);

    And the error was located in my groupSorter function named compareGroups. 

    Maybe, your problem is pretty the same as me. But as Song Tian said, we need more information on your code to reproduce and localize the problem.

    For more information about createGrouped function, you can refer to this page : List.createGrouped method (Windows)



    Tuesday, January 15, 2013 9:29 AM
  • THANK YOU!!!!  You saved me a ton of time.

    I found my problem right in the groupSorter function too.  Step through, and make sure that you're following the rules in that link, specifically:


    Type: Function

    A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).

    Make sure that whatever is being returned is a) a numeric, b) a numeric which makes sense given the context above.
    • Edited by mdhar Thursday, January 9, 2014 3:34 AM
    Thursday, January 9, 2014 3:33 AM