locked
How to sort a grouped Listview RRS feed

  • Question

  • Hi,

    I am trying to create an store app that displays files & folders in a grouped Listview. The first part to group by files & folders is done and in the right order.

    But I also want to order the folders & files listing alphabetically. I tried to first sort the elements with createSorted and then apply createGrouped to create the group but it doesn't work, the elements always end up shuffled.

    How do I go about this?

    Thanks


    Wednesday, May 29, 2013 9:50 AM

Answers

  • While creating the createGrouped the third parameter function can accept a soring function..

    var groupedSortedListProjection = 
    list.createGrouped(groupKey, groupData, groupSorter);

    You can use this function to specify your sorting algo and the rest should be done.

    MSDN says this about the third function:

    groupSorter

    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).

    Hope this helps..

    - Girija


    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria


    Thursday, May 30, 2013 11:50 PM

All replies

  • While creating the createGrouped the third parameter function can accept a soring function..

    var groupedSortedListProjection = 
    list.createGrouped(groupKey, groupData, groupSorter);

    You can use this function to specify your sorting algo and the rest should be done.

    MSDN says this about the third function:

    groupSorter

    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).

    Hope this helps..

    - Girija


    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria


    Thursday, May 30, 2013 11:50 PM
  •  Is it possible to call the groupSorter explicitly? instead of when generate data in first time?

    I have a function with input parameter, and i want sort the data by different type.

    Thanks!

    Monday, September 9, 2013 12:54 PM