1

如果网格有锁定的列,我遇到了列过滤器不正确的错误

这是小提琴:sencha fillde

重现步骤:(不应用任何过滤器)

  1. 打开“电子邮件”列菜单
  2. 打开“名称”列菜单(这是锁定的列)
  3. 打开“电话”栏菜单(注意过滤器菜单不正确,它显示了“电子邮件”栏的过滤器)。

对于没有“锁定”列的网格,过滤器菜单工作正常,感谢任何可以提供帮助的人!

4

1 回答 1

0

好吧,这个有点棘手。事实证明,对于锁定的网格,Ext.grid.filters.Filters:onMenuCreate会被击中两次……显示的网格菜单的每一侧都有一个。问题是在onMenuCreate 中,框架不考虑 2 个菜单。它只关心创建的最后一个菜单并销毁前一个菜单的侦听器。在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();
    }
});
于 2020-08-19T05:00:33.587 回答