ExtJS 7 -列筛选器锁定列时出现问题

py49o6xq  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(220)

我遇到了这样的错误:如果网格中有一个锁定的列,则列过滤器不正确
小提琴是这样的: Sencha 平原
重现步骤:(不应用任何筛选器)
1.打开“电子邮件”栏菜单
1.打开“名称”列菜单(这是锁定的列)
1.打开“电话”列菜单(注意过滤器菜单不正确,它显示的是“电子邮件”列的过滤器)。
对于没有“锁定”列的网格,过滤器菜单工作正常,感谢任何可以帮助的人!

hgqdbh6s

hgqdbh6s1#

好吧,这个有点棘手。事实证明,对于一个锁定的网格,Ext.grid.filters.Filters:onMenuCreate会被点击两次......分别对应于显示的网格菜单的两侧。问题是,在onMenuCreat e中,框架没有考虑这两个菜单。它只关心最后创建的菜单,并破坏前一个菜单的侦听器。在onMenuBeforeShow中,这个框架确实考虑了网格的每一边,所以我将这个想法扩展到一个覆盖中。我鼓励你为此创建一个 Sencha 支持票证,如果你没有访问权限,请告诉我,这样我就可以提交一个。

Ext.override(Ext.grid.filters.Filters, {
    onMenuCreate: function (headerCt, menu) {
        var me = this;

        // TODO: OLD BAD CODE... this would destroy the first menu's listeners
        // if (me.headerMenuListeners) {
        //     Ext.destroy(me.headerMenuListeners);
        //     me.headerMenuListeners = null;
        // }

        // me.headerMenuListeners = menu.on({
        //     beforeshow: me.onMenuBeforeShow,
        //     destroyable: true,
        //     scope: me
        // });

        // Just like in the onMenuBeforeShow, we need to create a hash of our menus
        // and their listeners... if we don't, we remove the 1st menu's listeners
        // when the 2nd menu is created
        if (!me.headerMenuListeners) {
            me.headerMenuListeners = {};
        }

        var parentTableId = headerCt.ownerCt.id;
        var menuListener = me.headerMenuListeners[parentTableId];
        if (menuListener) {
            Ext.destroy(menuListener);
            me.headerMenuListeners[parentTableId] = null;
        }

        me.headerMenuListeners[parentTableId] = menu.on({
            beforeshow: me.onMenuBeforeShow,
            destroyable: true,
            scope: me
        });
    },

    destroy: function () {
        var me = this,
            filterMenuItem = me.filterMenuItem,
            item;

        // TODO: ADDING THIS AND REMOVING FROM THE Ext.destroy on the next line
        var headerMenuListeners = this.headerMenuListeners;
        Ext.destroy(me.headerCtListeners, me.gridListeners);

        me.bindStore(null);
        me.sep = Ext.destroy(me.sep);

        for (item in filterMenuItem) {
            filterMenuItem[item].destroy();
        }

        // TODO: ADDING THIS AND REMOVING FROM THE Ext.destroy on the next line
        for (item in headerMenuListeners) {
            headerMenuListeners[item].destroy();
        }

        this.callParent();
    }
});

相关问题