-
1 Oct 2012 1:09 AM #1
Ext.data.TreeStore.removeAll() should respect the 'silent' config
Ext.data.TreeStore.removeAll() should respect the 'silent' config
Ext version tested:
- Ext 4.x
- The remoevAll() method of Ext.data.TreeStore should accept a parameter to control the 'silent' removing of records just like Ext.data.Store
- The current implementation of Ext.data.TreeStore.removeAll() is
Code:// inherit docs removeAll: function() { var root = this.getRootNode(); if (root) { root.destroy(true); } this.fireEvent('clear', this); },
Code:// inherit docs removeAll: function(silent) { var root = this.getRootNode(); if (root) { root.destroy(true); } if(silent !== true){ this.fireEvent('clear', this); } },
-
1 Oct 2012 2:52 AM #2
Not really a bug, since the docs don't list it as a parameter, but would be nice to have for consistency.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
1 Oct 2012 5:36 AM #3
True.
Is there a bug with destroying records in TreeStore? I see that when removeAll() is called all children of the tree generate a request to the server-side 'destroy' operation. this should not be the case when the node is destroyed with silent = true , right ?
Code:removeAll: function() { var root = this.getRootNode(); if (root) { root.destroy(true); // -> this should ensure no destroy operations are performed , but it doesn't ? } this.fireEvent('clear', this); },
-
1 Oct 2012 8:20 AM #4
Since remove all on TreeStore triggers the destroy operation on the store proxy I have created an override to support the silent config on the TreeStore.
When the root is destroyed this triggers the destruction of all its children and executes the 'destroy' operation on all of them. I don't think that should be happening when silent removing is used just like it doesn't with the regular Ext.data.Store.
Any improvements are more than welcomed!
Code:Ext.define('Ext.overrides.data.TreeStore', { override: 'Ext.data.TreeStore', removeAll: function(silent) { var me = this, root = me.getRootNode(); if(silent !== true){ if (root) { // will fire the 'destroy' operation for every child of the root root.destroy(true); } //fire the clear even only if not silent this.fireEvent('clear', me); }else{ if (root) { // temporarily remove the onNodeRemove event listener so that when removeAll is called, // the removed nodes do not get added to the removed array me.tree.un('remove', me.onNodeRemove, me); root.removeAll(false); // silent remove all children root.destroy(false); // destroy just the root // reattach the onNodeRemove listener me.tree.on('remove', me.onNodeRemove, me); } } } });
You found a bug! We've classified it as
EXTJSIV-7401
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote