PDA

View Full Version : [OPEN-497][3.1] Tree with treeFilter errors on reload()



djSeverin
22 Dec 2009, 11:08 PM
Update from ExtJS 3.0.3 to ExtJS 3.1.0 Supported release;
ExtJS connector.

-----------------------------------

I am currently stumped on the following problem and would love it if someone could give me some clues as to where to go looking to solve this one.

Our application uses a treeFilter that is filtering by date. This works just nicely in 3.0.3.

-----------------------------------

Using 3.1.0:
- The filter does work correctly on load;
- The filter fails when reload() is called no matter which node is selected;
- Resulting in the following error on the FireBug console:


When using ext-all.js:
- c.ui is null
- Ext.DomHelper=function(){var t=null,k=/^...dblclick",this.onNodeDblClick,this)}});\n

When using ext-all-debug.js:
- n.ui is null
- n.ui.show();\nIf "remove" is set to true when the treeFilter is instantiated, it will reload() without erroring; however, once a node has been filtered out of the tree, its gone for good. This behavior is exactly how remove should work; though I can't understand why: when "remove" is false, the above error occurs on refresh.


This will allow the root node to reload() without throwing an error:
this.viewFilter = new Ext.tree.TreeFilter(root.tree,{
autoClear : true,
remove : true
});This errors when root node is reload()ed:
this.viewFilter = new Ext.tree.TreeFilter(root.tree,{
autoClear : true,
remove : false
});Maybe the answer is right in front of me but I can't see it due to all these damned shiny christmas thingies strewn all over the office *rolls eyes* :-/

djSeverin
22 Dec 2009, 11:19 PM
Sorry, should have included this in the original post. This function is called on load, and when the slider's value changes.

this.filterMyTree = function(){
var value = root.getSliderDate().format('Y-m-d');
root.viewFilter.filterBy(
function(node)
{
var startDate = node.attributes.start_date;
var endDate = node.attributes.end_date;

if(startDate <= value && value < endDate)
{
return true;
}
else
{
return false;
// return true; <-- If true is returned, no problems occur... nfi what the go is
}
}
);
};

Condor
23 Dec 2009, 4:52 AM
TreeFilter doesn't know about the node reload, so it can still hold filtered nodes that aren't valid anymore after the reload.

You have to clear the filter before reloading and apply it again after reloading.

djSeverin
23 Dec 2009, 7:42 PM
Hi Condor, thanks for the hint.

I called clear() on my treeFilter before calling reload() on the selected tree node. After the node has reloaded, I reapply my treeFilter.

This fixed the problem "mostly".

Now the problem only occurs after a number of refresh's have been initiated by the user and then the user calls filterBy() due to a change in the date range. The problem is now random, only happening one in every 20 or so changes of the date range; but only ever after reload() has been called on one or more nodes.

I am completely stumped. :(( The problem is occuring in the treeFilter on clear(), but I haven't been able to work out if its:
a) the clear() that is called on the treeFilter when the user requests a node refresh, or
b) if its occuring in the filterBy() function of the treeFilter due to the treeFilter being instantiated with autoClear set to true.



@class Ext.tree.TreeFilter

clear : function(){
var t = this.tree;
var af = this.filtered;
for(var id in af){
if(typeof id != "function"){
var n = af[id];
if(n){
n.ui.show(); <-- This is the line it dies on...
}
}
}
this.filtered = {};
}As I mentioned above, this doesn't happen in ExtJS 3.0.x; only in 3.1.x

What changes were made to tree? Were there any changes made to treeFilter?

Condor
23 Dec 2009, 11:18 PM
The problem was introduced by the following line:

Ext.override(Ext.tree.TreeNodeUI, {
destroy : function(){
if(this.elNode){
Ext.dd.Registry.unregister(this.elNode.id);
}
Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){
if(this[el]){
Ext.fly(this[el]).remove();
delete this[el];
}
}, this);
delete this.node;
}
});
(try removing it)

ludoo
7 Jan 2010, 2:03 AM
Hi,

I've got exactly the same bug !
Is there any news about this ??

I tried to remove "delete this.node;" but it doesn't help !!

I now add a check on n.ui in TreeFilter.clear():
It seems solve the pb !


Ext.override(Ext.tree.TreeFilter {
clear : function(){
var t = this.tree;
var af = this.filtered;
for(var id in af){
if(typeof id != "function"){
var n = af[id];
if(n && n.ui){
n.ui.show();
}
}
}
this.filtered = {};
}
});

ajpfister
27 Jan 2010, 10:36 AM
ludoo,

have you seen the problem come back after implementing your "fix"?

thanks,
Adam

djSeverin
19 Aug 2010, 9:28 PM
condor - RE: http://www.sencha.com/forum/showthread.php?88400-OPEN-497-3.1-Tree-with-treeFilter-errors-on-reload()&p=422004#post422004 - Didn't work

ludoo - Your fix worked perfectly. Thankyou.

Would this fix please be comitted to the svn?