Search code examples
listsencha-touch-2

Sencha Touch list store disable sorting


I have my list which is getting data from php service, the data received is in the order I need. But sencha automatically sort my list alphabetically. Below is my code:

Ext.define('MyList', {
    extend: 'Ext.dataview.List',

    config:     {
        grouped: true,
        plugins: [
            {
                xclass:          'Ext.plugin.PullRefresh',
                pullRefreshText: 'Pull down to refresh'

            },
            {
                xclass:     'Ext.plugin.ListPaging',
                autoPaging: true,
                noMoreRecordsText: 'No More Records'

            }
        ]
    },
    initialize: function () {
        this.callParent(arguments);
        var store = Ext.create('Ext.data.Store', {

            pageParam: 'page',
            grouper: {
                groupFn: function (record) {
                    return record.data.group_label;
                }
            },
            model:   'ListItem',
            proxy:   {
                type:   'ajax',
                url:    '/m/services/activity_list_items.php',
                reader: {
                    type:         'json',
                    rootProperty: 'root.results'
                }
            }
        });

        var template = Ext.create('GenericListItem', {
            hascounts: true,
            hasicon:   true,
            varmap:    {
                descr:  'subtext',
                count:  'sub_item_cnt',
                itemid: 'itemid',
                uniqid: 'uniqid'
            }
        });

        var emptyText = 'Recent Activity Items';
        this.setStore(store);
        this.setItemTpl(template);
        this.setEmptyText(emptyText);
    }
});

How can I avoid the auto sorting of list?


Solution

  • Add the following to your store config.

    remoteSort : true,
    

    remoteSort defaults to false in sencha. So sencha automatically sorts in the client side. Check the link for more details http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Store-cfg-remoteSort