PDA

View Full Version : Tree Examples and empty folders



Evolic
27 Sep 2007, 6:38 AM
Hi all,
I'm new one here and I'm just starting my adventure with Ext JS.
I want to create tree with checkboxes.
I started with standard examples attached to Ext version 1.1.1.
During my tests I noticed that there is some problem with Tree.
If I add an empty folder to Ext source, and click on plus to expand that folder
icon of that object changes to file type, but properties shows that it is still a folder.
For me some CSS classes are changed, but I can't find where and what is changed.
The problem exists in Reorder demo, in TwoTrees all is OK.
Any ideas?

Second Question: is there any fast method to refresh some Tree Node?
E.g. select node and click on button Refresh, but I don't know what method should be assigned to onclick event?

ndtreviv
13 Oct 2008, 8:19 AM
If I add an empty folder to Ext source, and click on plus to expand that folder
icon of that object changes to file type, but properties shows that it is still a folder.


I have this problem also. When I click to expand an empty folder, even though leaf is set to false, it changes the icon to a leaf icon and it no longer works as a dropzone. Flipping annoying.

I'm guessing this is something to do with the updateExpandIcon function in TreeNodeUI. Is there some setting that I can put in to stop it doing this?

ndtreviv
2 Feb 2009, 9:16 AM
I know how frustrating it can be when you think you've found a thread with a solution on it, and it just ends with no solution at all!

Therefore, I'm putting the solution to this problem that I found here:

Ext.tree.TreeNodeUI.prototype.updateExpandIcon = Ext.tree.TreeNodeUI.prototype.updateExpandIcon.createSequence(function() {
/* This is called after the Ext.tree.TreeNodeUI.updateExpandIcon method has finished and adds
the following process to that method.
If we have flagged that this node is to remain a folder whether or not is has children,
and it has just been made into a leaf (as indicated by wasLeaf now being true),
then reverse what the updateExpandIcon method just did and turn it back into a closed (collapsed) folder.
*/
if (this.node.attributes.isfolder && this.wasLeaf) {
this.removeClass("x-tree-node-leaf");
this.addClass("x-tree-node-expanded");
this.c1 = "x-tree-node-collapsed";
this.c2 = "x-tree-node-expanded";
this.wasLeaf = false;
}
});


Thing is...I can't quite remember where it came from! Sorry...
Anyway, this did it for me. Hope it does it for you too :)