PDA

View Full Version : [FIXED][3.0.0] Ext.ux.grid.RowExpander and onDestroy problem



fermo111
9 Jul 2009, 7:25 AM
The onDestroy from the Ext.ux.grid.RowExpander plugin (examples/ux/RowExpander.js) is defined as follows:

onDestroy: function() {
this.keyNav.disable();
delete this.keyNav;
var mainBody = this.grid.getView().mainBody;
mainBody.un('mousedown', this.onMouseDown, this);
},

When the line in red is executed, I get an error saying that 'mainBody is undefined'. After some debugging I found that the 'mainBody' of the grid view is deleted before this method is called. The call order seems to be as follows:

Ext.grid.GridPanel.onDestroy()
Ext.grid.GridView.destroy()
-- destroys the view mainBody
Ext.ux.grid.RowExpander.onDestroy()


In fact the Ext.Component destroy() method executes the following statements:

this.onDestroy();
Ext.ComponentMgr.unregister(this);
this.fireEvent('destroy', this);


The first line results in destroying the grid view mainBody and the last line executes Ext.ux.grid.RowExpander.onDestroy() which is an event handler on the grid 'destroy' event.

evant
9 Jul 2009, 9:05 AM
Fixed in the trunk r4779, thanks.

shukurove
10 Aug 2009, 4:11 AM
from wich version fixed this problem ?
i download last version (3.0.0), but this problem still exist

evant
10 Aug 2009, 4:26 AM
Yes, it was fixed after 3.0 was released, it will be in the next patch version.

zombeerose
3 Sep 2009, 11:11 AM
I am also getting a 'this.grid is undefined' error on line 61665 of ext-all-debug (Ext 3.0.0). The error only occurs when destroying grids that use the RowExpander. Does the svn code also fix this issue?

evant
3 Sep 2009, 6:59 PM
Yes, if you grab the latest from SVN it will be resolved.

axpa
30 Mar 2010, 11:15 PM
I still get the error mainBody is undefined in the onDestroy and I use 3.1.1.
So I have changed it to use grid.mon would that work fine?

// @private
onRender: function() {
var grid = this.grid;
// var mainBody = grid.getView().mainBody;
grid.mon(grid.getView().mainBody, 'mousedown', this.onMouseDown, this, {delegate: '.x-grid3-row-expander'});
// mainBody.on('mousedown', this.onMouseDown, this, {delegate: '.x-grid3-row-expander'});
if (this.expandOnEnter) {
this.keyNav = new Ext.KeyNav(this.grid.getGridEl(), {
'enter' : this.onEnter,
scope: this
});
}
if (this.expandOnDblClick) {
grid.on('rowdblclick', this.onRowDblClick, this);
}
},

// @private
onDestroy: function() {
this.keyNav.disable();
delete this.keyNav;
// var mainBody = this.grid.getView().mainBody;
// mainBody.un('mousedown', this.onMouseDown, this);
},