PDA

View Full Version : [FIXED-653] Bug in GridPanel.processEvent; this.view is null when used



awebb
4 Jan 2010, 6:05 AM
In GridPanel.processEvent() in 3.1.0 (as opposed to 3.0.3), the view's "processEvent" method is also called. The trouble is that this.view can be reset to null during the execution of the method, causing the this.view.processEvent() call to fail. The fix is simple: use the cached copy of this.view to make the method call (in local variable 'v').

I.e.


processEvent : function(name, e){
this.fireEvent(name, e);
var t = e.getTarget(),
v = this.view,
header = v.findHeaderIndex(t);

if(header !== false){
this.fireEvent('header' + name, this, header, e);
}else{
var row = v.findRowIndex(t),
cell,
body;
if(row !== false){
this.fireEvent('row' + name, this, row, e);
cell = v.findCellIndex(t);
body = v.findRowBody(t);
if(cell !== false){
this.fireEvent('cell' + name, this, row, cell, e);
}
if(body){
this.fireEvent('rowbody' + name, this, row, e);
}
}else{
this.fireEvent('container' + name, this, e);
}
}
// this.view.processEvent(name, e); DON'T DO THIS
v.processEvent(name, e); DO THIS INSTEAD
},
Andrew

Condor
4 Jan 2010, 6:25 AM
Any event handler could cause the grid to be destroyed, so IMHO a safer solution is to use:

Ext.override(Ext.grid.GridPanel, {
processEvent : function(name, e){
this.view.processEvent(name, e);
}
});
Ext.override(Ext.grid.GridView, {
processEvent : function(name, e){
var t = e.getTarget(),
g = this.grid,
header = this.findHeaderIndex(t);
g.fireEvent(name, e);
if(header !== false){
g.fireEvent('header' + name, g, header, e);
}else{
var row = this.findRowIndex(t),
cell,
body;
if(row !== false){
g.fireEvent('row' + name, g, row, e);
cell = this.findCellIndex(t);
if(cell !== false){
g.fireEvent('cell' + name, g, row, cell, e);
}else{
body = this.findRowBody(t);
if(body){
g.fireEvent('rowbody' + name, g, row, e);
}
}
}else{
g.fireEvent('container' + name, g, e);
}
}
}
});
Ext.override(Ext.grid.GroupingView, {
processEvent: function(name, e){
Ext.grid.GroupingView.superclass.processEvent.call(this, name, e);
var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
if(hd){
var field = this.getGroupField(),
prefix = this.getPrefix(field),
groupValue = hd.id.substring(prefix.length);
groupValue = groupValue.substr(0, groupValue.length - 3);
if(groupValue){
this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
}
}
}
});

elishnevsky
24 Feb 2010, 8:42 AM
Just bumping this thread. This defect deserves attention.

Jamie Avins
5 Mar 2010, 12:56 PM
[type]: fix
[module]: Grid
[id]: #653
[desc]: Fixed #653. ProcessEvent moved to GridView and called from GridPanel. This will allow the view to dynamically change during and event and still function properly.

mynameisyoda
9 Apr 2010, 8:15 AM
Please in what SVN version is the Fix? in 3.1.2 the problem still persists (with our code at least...)

Jamie Avins
9 Apr 2010, 8:29 AM
SVN 6235 for the 3.2.x branch since it was a major code shift between classes.