Sencha触摸列表商店禁用排序



我有我的列表,该列表正在从PHP服务中获取数据,收到的数据按我需要的顺序。但是Sencha会自动按字母顺序对我的列表进行排序。以下是我的代码:

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);
    }
});

如何避免列表的自动排序?

将以下内容添加到您的商店配置。

remoteSort : true,

远程默认值默认为sencha中的false。因此,sencha自动在客户端中分类。检查链接以获取更多详细信息http://docs.sencha.com/touch/2-0/#!/ext.data.store-cfg-remotesort

只需删除以下内容:

grouped: true

从列表配置中,如果您不需要每个项目的标题,并且强制删除此信息:

grouper: {
    groupFn: function (record) {
        return record.data.group_label;
    }
}

来自您的商店,因为基本上在您的情况下,grouper属性正在根据您的group_label字段按字母顺序分组。希望它有帮助:)

最新更新