Destroying an EditorGridPanel's ColumnModel does not destroy any GridEditors defined in its ColumnModel, resulting in a memory leak.
to reproduce this problem, type the following into the Firebug console in the Editor Grid Example:
Code:
var grid = Ext.getCmp(Ext.get('editor-grid').first().id);
var id = grid.getColumnModel().getCellEditor(3, 0).field.id; // get the "Available" column's DateField id
console.log(Ext.getCmp(id)); // verify that we've got the correct component
grid.destroy(); // destroy the editorgrid
console.log(Ext.getCmp(id)); // DateField is still registered with the ComponentMgr -- i.e. it hasn't been destroyed
the following override resolves this (without destroying the ColumnModel, but rendering the same ColumnModel unusable for other EditorGridPanels):
Code:
Ext.override(Ext.grid.EditorGridPanel, {
onDestroy: function() {
var cols = this.getColumnModel().config;
for(var i = 0, len = cols.length; i < len; i++){
var c = cols[i];
Ext.destroy(c.editor);
}
Ext.grid.EditorGridPanel.superclass.onDestroy.call(this);
}
});
1 question remains though -- should the ColumnModel for the EditorGridPanel also be destroyed when it is destroyed?
For a GridPanel, it makes sense not to destroy the ColumnModel since it can in theory be re-used (so the GridPanel.onDestroy() method is correct in simply purging the ColumnModel's listeners).
For an EditorGridPanel though, though it is perfectly ok to reuse its ColumnModel in a different EditorGridPanel, there's no ColumnModel.destroy() method to mop up any lingering GridEditors should the ColumnModel be destroyed (i.e. simply nullfied).