Sencha Touch列表存储禁用排序。

3

我有一个列表,从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);
    }
});

如何避免列表的自动排序?
2个回答

7

谢谢,好的解决方案! - Nadia

2

只需删除此内容:

grouped: true

如果您不希望每个项目都有标题,并且必须删除此内容,则可以从列表配置中进行更改:

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

从您的商店购买,因为在您的情况下,grouper 属性是基于您的 group_label 字段按字母顺序对项目进行分组。希望这有所帮助 :)


也许他仍然想要将它们分组,但不排序? - Titouan de Bailleul
是的,我想按group_label分组,但不排序。 - amrit_neo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接