View Full Version : [Solved] Ext.grid.Grid.destroy() not removing listeners in DS + FIX

Artur Bodera (Joust)
17 Jul 2007, 2:44 AM
Hello folks!

1. Create a grid, with DS and CM.
2. GridView.init() is called, which calls GridView.bind() in line 96 (GridView.js)
3. bind() attaches to data store with ds.on(... , ... , this ) GridView scope
4. We destroy the grid with grid.destroy(true)
5. Ext.grid.Grid.destroy() calls GridView.destroy()
6. On line 1157 (GridView.js) bind function gets called again with: this.bind(null,null)
7. this.ds.un( ... , ... ) is called, but with no scope override;
8. Event.findListener(fn, null) --- no listener is found, because scope has changed, fn is not to be found and listener is NOT removed.
9. During next DS update (ie. reload) error is thrown (trying to update non-existent grid)

Use the same scope override for un() as for on(), change lines 58-63 (GridView.js) or 26961-26966 (ext-all-debug.js):

this.ds.un("load", this.onLoad, this);
this.ds.un("datachanged", this.onDataChange);
this.ds.un("add", this.onAdd);
this.ds.un("remove", this.onRemove);
this.ds.un("update", this.onUpdate);
this.ds.un("clear", this.onClear);
change to:

this.ds.un("load", this.onLoad, this);
this.ds.un("datachanged", this.onDataChange,this);
this.ds.un("add", this.onAdd,this);
this.ds.un("remove", this.onRemove,this);
this.ds.un("update", this.onUpdate,this);
this.ds.un("clear", this.onClear,this);
Have a nice day.

17 Jul 2007, 6:03 AM
thanks for the detailed analysis, but which version are you referring to :-/

Artur Bodera (Joust)
6 Aug 2007, 10:47 AM
bug in 1.1 RC1. Don't have access to svn, and haven't tied 1.1 final.

Artur Bodera (Joust)
6 Aug 2007, 11:12 PM
You fixed it in 1.1 final - thanks!

7 Aug 2007, 12:17 AM
You fixed it in 1.1 final - thanks!

it wasn't me. :)