标签内的EXTJS网格-过滤器仅在页面刷新时有效

时间:2019-06-11 13:19:03

标签: extjs extjs4.1

我们正在使用extjs 4.1,我遇到了一个奇怪的问题。我们有3个标签组,这些标签包含extjs网格。前2个中的extjs网格可以很好地加载数据,并且还具有过滤器选项。第3个标签中的extjs网格,加载数据但不显示过滤器菜单。但是,在第3个选项卡上刷新页面时,网格将显示过滤器菜单。我是extjs的新手。请帮忙。

ext-all-debug-w-comments-v4.1.2a.js:144232 Uncaught TypeError: Cannot read property 'enable' of null
at constructor.showMenuBy (ext-all-debug-w-comments-v4.1.2a.js:144232)
at constructor.onHeaderTriggerClick (ext-all-debug-w-comments-v4.1.2a.js:141028)
at constructor.onElClick (ext-all-debug-w-comments-v4.1.2a.js:142124)
at HTMLDivElement.eval (eval at cacheableFunctionFactory (ext-all-debug-w-comments-v4.1.2a.js:683), <anonymous>:6:13)
at HTMLDivElement.wrap (ext-all-debug-w-comments-v4.1.2a.js:15197)

以下行是发生错误的地方,但此行在extjs中

 showMenuBy: function(t, header) {
    var menu = this.getMenu(),
        groupMenuItem  = menu.down('#groupMenuItem'), //this menu is null and therefore the error but this is auto generated by extjs
        groupMenuMeth = header.groupable === false ?  'disable' : 'enable',
        groupToggleMenuItem  = menu.down('#groupToggleMenuItem');

    groupMenuItem[groupMenuMeth](); //this statement is null and throws the error
    if (groupToggleMenuItem) {
        groupToggleMenuItem[this.view.store.isGrouped() ?  'enable' : 'disable']();
    }
    Ext.grid.header.Container.prototype.showMenuBy.apply(this, arguments);
}

//来自onHeaderTrigerClick stackTrace的代码:

onHeaderTriggerClick: function(header, e, t) {
    // generate and cache menu, provide ability to cancel/etc
    var me = this;
    if (header.fireEvent('headertriggerclick', me, header, e, t) !== false && me.fireEvent("headertriggerclick", me, header, e, t) !== false) {
        me.showMenuBy(t, header);
    }
}

//来自onElClick的代码:

  onElClick: function(e, t) {

    // The grid's docked HeaderContainer.
    var me = this,
        ownerHeaderCt = me.getOwnerHeaderCt();

    if (ownerHeaderCt && !ownerHeaderCt.ddLock) {
        // Firefox doesn't check the current target in a within check.
        // Therefore we check the target directly and then within (ancestors)
        if (me.triggerEl && (e.target === me.triggerEl.dom || t === me.triggerEl.dom || e.within(me.triggerEl))) {
            ownerHeaderCt.onHeaderTriggerClick(me, e, t);
        // if its not on the left hand edge, sort
        } else if (e.getKey() || (!me.isOnLeftEdge(e) && !me.isOnRightEdge(e))) {
            me.toggleSortState();
            ownerHeaderCt.onHeaderClick(me, e, t);
        }
    }
}

2 个答案:

答案 0 :(得分:1)

在每种情况下,参数headernull

请参见Ext.grid.feature.Grouping

答案 1 :(得分:0)

这似乎是一个CSS问题,可能是由组件加载到标头的高度和高度的顺序引起的。 在CSS下方使用:

Ubuntu

标识标头组件的ID,并使用它代替 .ui-grid-header-cell