ExtJS 4.2.1中的网格分组和排序 [英] Grid grouping and sorting in ExtJS 4.2.1

查看:239
本文介绍了ExtJS 4.2.1中的网格分组和排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用类似于此示例的分组实现网格:
http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/groupgrid.html
这里的数据按美食和排序列分组按此列排序组相应。
当我将这个例子的代码粘贴到一个使用4.2.1的项目中,或者在ExtJS 4.2.1文档站点的代码编辑器中时,视图是完全相同的,排序对Name列进行排序,但是不符合美食栏目。
他们是否通过4.2.1中的列分组删除排序?如果没有,如何使其工作?

I try to implement grid with grouping similar to this example: http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/groupgrid.html Here data is grouped by column "Cuisine" and sorting by this column sort groups accordingly. When I paste code of this example into a project, which uses 4.2.1, or in code editor at ExtJS 4.2.1 docs site, the view is exactly the same, sorting works for column "Name", but it doesn't work by column "Cuisine". Did they remove sorting by grouping column in 4.2.1? If not, how to make it work?

推荐答案

同样的例子在4.2.1 SDK中,确实按照分组列不再工作。听起来像回归给我,你应该通知Sencha。

The same example is present in 4.2.1 SDK, and indeed sorting by the grouped column doesn't work anymore. Sounds like a regression to me, you should notify Sencha.

编辑:

这是方法的代码sort $ sort $ sort $ / code>已更改。恢复以前的版本修复了行为(请参阅我的评论以找到修改的行):

That's the code of the method Ext.data.Store#sort that has changed. Restoring the previous version fixes the behaviors (see my comments to find the modified lines):

Ext.define(null, {
    override: 'Ext.data.Store'

    ,sort: function(sorters, direction, where, doSort) {
        var me = this,
            sorter,
            newSorters;

        if (Ext.isArray(sorters)) {
            doSort = where;
            where = direction;
            newSorters = sorters;
        }
        else if (Ext.isObject(sorters)) {
            doSort = where;
            where = direction;
            newSorters = [sorters];
        }
        else if (Ext.isString(sorters)) {
            sorter = me.sorters.get(sorters);

            if (!sorter) {
                sorter = {
                    property : sorters,
                    direction: direction
                };
                newSorters = [sorter];
            }
            else if (direction === undefined) {
                sorter.toggle();
            }
            else {
                sorter.setDirection(direction);
            }
        }

        if (newSorters && newSorters.length) {
            newSorters = me.decodeSorters(newSorters);
            if (Ext.isString(where)) {
                if (where === 'prepend') {
                    // <code from 4.2.1>
                    // me.sorters.insert(0, newSorters);
                    // </code from 4.2.1>

                    // <code from 4.2.0>
                    sorters = me.sorters.clone().items;

                    me.sorters.clear();
                    me.sorters.addAll(newSorters);
                    me.sorters.addAll(sorters);
                    // </code from 4.2.0>
                }
                else {
                    me.sorters.addAll(newSorters);
                }
            }
            else {
                me.sorters.clear();
                me.sorters.addAll(newSorters);
            }
        }

        if (doSort !== false) {
            me.fireEvent('beforesort', me, newSorters);
            me.onBeforeSort(newSorters);

            sorters = me.sorters.items;
            if (sorters.length) {

                me.doSort(me.generateComparator());
            }
        }
    }
});

这篇关于ExtJS 4.2.1中的网格分组和排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆