嵌套网格中的 ExtJS 错误:无法读取 属性 'isGroupHeader' of null
ExtJS error in nested grids : Cannot read property 'isGroupHeader' of null
每当我在嵌套网格中展开或折叠行时,我都会收到以下错误:
"Uncaught TypeError: Cannot read property 'isGroupHeader' of null"
google 给了我这个 url ,但它似乎在 5.1 中不起作用,知道如何转换它来解决 5.1 问题吗?
http://blog.kondratev.pro/2014/08/getting-rid-of-annoying-uncaught.html
这是错误的 fiddle 示例:
https://fiddle.sencha.com/#fiddle/g5b
发生这种情况是因为在另一个网格(父级或祖先级)的上下文中触发了网格单元格或单元格编辑器事件(鼠标悬停、单击或其他)。在这里你可以看到如何阻止事件冒泡:
Ext.require(['Nested.view.NestedGrid'], function() {
var nGrid = Ext.create({
type: 'nestedgrid',
renderTo: div
});
// prevent bubbling of the events
nGrid.getEl().swallowEvent([
'mousedown', 'mouseup', 'click',
'contextmenu', 'mouseover', 'mouseout',
'dblclick', 'mousemove'
]);
});
找到ext-all-debug.js源码错误方法,加载后新建js到"ext-all *. Js"位置,我的版本是:Ext JS 6.2.0.981
核心代码为:Object.prototype
.function and xxx != null
后缀代码:
Ext.event.publisher.Dom.prototype.unsubscribe = function (element, eventName, delegated, capture) {
var me = this,
captureSubscribers, bubbleSubscribers, subscribers, id;
if (delegated && !me.directEvents[eventName]) {
captureSubscribers = me.captureSubscribers;
bubbleSubscribers = me.bubbleSubscribers;
subscribers = capture ? captureSubscribers : bubbleSubscribers;
if (subscribers != null && subscribers[eventName]) {
--subscribers[eventName];
}
if (me != null && bubbleSubscribers != null && captureSubscribers != null && !me.handles[eventName] && !bubbleSubscribers[eventName] && !captureSubscribers[eventName]) {
// decremented subscribers back to 0 - and the event is not in "handledEvents"
// no longer need to listen at the dom level
this.removeDelegatedListener(eventName);
}
} else {
subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
id = element.id;
subscribers = subscribers[eventName];
if (subscribers[id]) {
--subscribers[id];
}
if (!subscribers[id]) {
// no more direct subscribers for this element/id/capture, so we can safely
// remove the dom listener
delete subscribers[id];
me.removeDirectListener(eventName, element, capture);
}
}
};
Ext.define('MyApp.overrides.GridColumn', {
override: 'Ext.grid.column.Column',
show: function () {
if (!this.getRefOwner()) {
return;
}
this.callParent(arguments);
}
});
这是我正在使用的解决方法。
每当我在嵌套网格中展开或折叠行时,我都会收到以下错误:
"Uncaught TypeError: Cannot read property 'isGroupHeader' of null"
google 给了我这个 url ,但它似乎在 5.1 中不起作用,知道如何转换它来解决 5.1 问题吗?
http://blog.kondratev.pro/2014/08/getting-rid-of-annoying-uncaught.html
这是错误的 fiddle 示例: https://fiddle.sencha.com/#fiddle/g5b
发生这种情况是因为在另一个网格(父级或祖先级)的上下文中触发了网格单元格或单元格编辑器事件(鼠标悬停、单击或其他)。在这里你可以看到如何阻止事件冒泡:
Ext.require(['Nested.view.NestedGrid'], function() {
var nGrid = Ext.create({
type: 'nestedgrid',
renderTo: div
});
// prevent bubbling of the events
nGrid.getEl().swallowEvent([
'mousedown', 'mouseup', 'click',
'contextmenu', 'mouseover', 'mouseout',
'dblclick', 'mousemove'
]);
});
找到ext-all-debug.js源码错误方法,加载后新建js到"ext-all *. Js"位置,我的版本是:Ext JS 6.2.0.981
核心代码为:Object.prototype
.function and xxx != null
后缀代码:
Ext.event.publisher.Dom.prototype.unsubscribe = function (element, eventName, delegated, capture) {
var me = this,
captureSubscribers, bubbleSubscribers, subscribers, id;
if (delegated && !me.directEvents[eventName]) {
captureSubscribers = me.captureSubscribers;
bubbleSubscribers = me.bubbleSubscribers;
subscribers = capture ? captureSubscribers : bubbleSubscribers;
if (subscribers != null && subscribers[eventName]) {
--subscribers[eventName];
}
if (me != null && bubbleSubscribers != null && captureSubscribers != null && !me.handles[eventName] && !bubbleSubscribers[eventName] && !captureSubscribers[eventName]) {
// decremented subscribers back to 0 - and the event is not in "handledEvents"
// no longer need to listen at the dom level
this.removeDelegatedListener(eventName);
}
} else {
subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
id = element.id;
subscribers = subscribers[eventName];
if (subscribers[id]) {
--subscribers[id];
}
if (!subscribers[id]) {
// no more direct subscribers for this element/id/capture, so we can safely
// remove the dom listener
delete subscribers[id];
me.removeDirectListener(eventName, element, capture);
}
}
};
Ext.define('MyApp.overrides.GridColumn', {
override: 'Ext.grid.column.Column',
show: function () {
if (!this.getRefOwner()) {
return;
}
this.callParent(arguments);
}
});
这是我正在使用的解决方法。