ExtJS 7 - 锁定列的列过滤器问题
ExtJS 7 - Column filter issue with locked column
我遇到了这个错误,如果网格有一个锁定的列,列过滤器就会不正确
这是 fiddle:sencha fillde
重现步骤:
(不应用任何过滤器)
- 打开“电子邮件”栏菜单
- 打开“姓名”列菜单(这是锁定的列)
- 打开“Phone”列菜单(注意过滤器菜单不正确,它显示的是“电子邮件”列的过滤器)。
对于没有 'locked' 列的网格,过滤器菜单工作正常,感谢任何可以提供帮助的人!
好吧,这个有点棘手。事实证明,对于锁定的网格,Ext.grid.filters.Filters:onMenuCreate
被击中两次……显示的网格菜单的每一侧各一次。问题是在 onMenuCreat
e 中,框架不考虑 2 个菜单。它只关心最后创建的菜单并销毁前一个菜单的监听器。在 onMenuBeforeShow
中,框架确实考虑了网格的每一侧,因此我将这个想法扩展为覆盖。我鼓励您为此创建一张 Sencha 支持票,如果您没有访问权,请告诉我,以便我提交一张。 Fiddle here.
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();
}
});
我遇到了这个错误,如果网格有一个锁定的列,列过滤器就会不正确
这是 fiddle:sencha fillde
重现步骤: (不应用任何过滤器)
- 打开“电子邮件”栏菜单
- 打开“姓名”列菜单(这是锁定的列)
- 打开“Phone”列菜单(注意过滤器菜单不正确,它显示的是“电子邮件”列的过滤器)。
对于没有 'locked' 列的网格,过滤器菜单工作正常,感谢任何可以提供帮助的人!
好吧,这个有点棘手。事实证明,对于锁定的网格,Ext.grid.filters.Filters:onMenuCreate
被击中两次……显示的网格菜单的每一侧各一次。问题是在 onMenuCreat
e 中,框架不考虑 2 个菜单。它只关心最后创建的菜单并销毁前一个菜单的监听器。在 onMenuBeforeShow
中,框架确实考虑了网格的每一侧,因此我将这个想法扩展为覆盖。我鼓励您为此创建一张 Sencha 支持票,如果您没有访问权,请告诉我,以便我提交一张。 Fiddle here.
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();
}
});