繁体   English   中英

Sencha Touch列表存储禁用排序

[英]Sencha Touch list store disable sorting

我的列表是从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,

remoteSort在sencha中默认为false。 因此,sencha在客户端自动排序。 查看链接以获取更多详细信息http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Store-cfg-remoteSort

只需删除此:

grouped: true

如果您不希望每个项目都有标题,则必须从列表配置中删除此项:

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

来自您的商店,因为基本上在您的情况下, grouper属性用于根据您的group_label字段按字母顺序对项目进行分组。 希望能帮助到你 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM