1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    67
    Answers
    3
    Vote Rating
    1
    Soenhay is on a distinguished road

      0  

    Default Answered: How to group a list but change the group order...

    Answered: How to group a list but change the group order...


    Hi,

    I am wondering if it is possible to change the order of a grouped list. For example:

    Code:
    Ext.define('a.store.S', {
        extend: 'Ext.data.Store',
        config:
        {
            model: 'a.model.S',
            grouper: {
                groupFn: function (record) {
                    return record.get('group').substr(2);
                }
            },
    
            data: [ 
                  {title: 'a title', group: '2-A group', url: 'some url'},
                  {title: 'b title', group: '2-A group', url: 'some url'},
                  {title: 'c title', group: '1-B group', url: 'some url'},
                  {title: 'd title', group: '1-B group', url: 'some url'},
                  {title: 'e title', group: '0-C group', url: 'some url'},
            ]
    This list will be grouped by the group field but the order of the groups would be as follows:
    A group
    B group
    C group

    If I do not use the substr method then the groups would be in the order that I desire but with the undesirable prefix:
    0-C group
    1-B group
    2-A group


    Is it possible to make the groups in this list ordered and displayed as follows?
    C group
    B group
    A group

  2. Thanks to j.k's response:
    j.k
    You can use sortProperty or sorterFn to sort your groups in any order you want to:

    http://docs.sencha.com/touch/2-0/#!/...t.util.Grouper
    I found this link:

    http://www.sencha.com/forum/showthre...e-in-ST2-beta1

    Which lead to this solution:

    Code:
    Ext.define('a.store.S', {
    extend: 'Ext.data.Store',
    config:
    {
        model: 'a.model.S',
        autoLoad: true,
        sorters: 'title',
        grouper: {
            sortProperty: 'group_index',
            groupFn: function (record) {
                return record.get('group_title');
            }
        },
        data: [
            {title: 'a title', group_title: 'A group', group_index: '1'},
            {title: 'b title', group_title: 'A group', group_index: '1'},
            {title: 'c title', group_title: 'B group', group_index: '2'},
            {title: 'd title', group_title: 'B group', group_index: '2'},
            {title: 'e title', group_title: 'C group', group_index: '0'},
        ]
    }
    Which will make the groups with the following titles and order:
    C group
    ---e title
    A group
    ---a title
    ---b title
    B group
    ---c title
    ---d title

    I changed the order from my original post to make it more clear.

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    49
    Answers
    6
    Vote Rating
    0
    j.k is on a distinguished road

      0  

    Default


    try:
    PHP Code:
    groupDir"DESC" 
    in your grouper config

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    67
    Answers
    3
    Vote Rating
    1
    Soenhay is on a distinguished road

      0  

    Default


    I do not mean grouping descending or ascending..... I mean to have the list grouped by whatever I want.. not necessarily in alphabetical or numerical or ascending/descending order......

  5. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    49
    Answers
    6
    Vote Rating
    0
    j.k is on a distinguished road

      0  

    Default


    You can use sortProperty or sorterFn to sort your groups in any order you want to:

    http://docs.sencha.com/touch/2-0/#!/...t.util.Grouper

  6. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    67
    Answers
    3
    Vote Rating
    1
    Soenhay is on a distinguished road

      0  

    Default


    Cool, that sounds more like what I want.. I am looking into it now.. Thanks for the quick response!

  7. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    67
    Answers
    3
    Vote Rating
    1
    Soenhay is on a distinguished road

      1  

    Default


    Thanks to j.k's response:
    j.k
    You can use sortProperty or sorterFn to sort your groups in any order you want to:

    http://docs.sencha.com/touch/2-0/#!/...t.util.Grouper
    I found this link:

    http://www.sencha.com/forum/showthre...e-in-ST2-beta1

    Which lead to this solution:

    Code:
    Ext.define('a.store.S', {
    extend: 'Ext.data.Store',
    config:
    {
        model: 'a.model.S',
        autoLoad: true,
        sorters: 'title',
        grouper: {
            sortProperty: 'group_index',
            groupFn: function (record) {
                return record.get('group_title');
            }
        },
        data: [
            {title: 'a title', group_title: 'A group', group_index: '1'},
            {title: 'b title', group_title: 'A group', group_index: '1'},
            {title: 'c title', group_title: 'B group', group_index: '2'},
            {title: 'd title', group_title: 'B group', group_index: '2'},
            {title: 'e title', group_title: 'C group', group_index: '0'},
        ]
    }
    Which will make the groups with the following titles and order:
    C group
    ---e title
    A group
    ---a title
    ---b title
    B group
    ---c title
    ---d title

    I changed the order from my original post to make it more clear.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar