PDA

View Full Version : how to hide a tree component node?


sushil_kokate
11-03-2006, 05:34 AM
Hi there!

I m using the tree component which is linked to different SWFs. I hav assigned a XML as dataProvider of the tree

Can we make a specific node in the tree invisible??

I want that node to b there in the tree data but dont want to display it. Is it possible for the tree component.

Plz help me out as i didnt find much tutorials on tree component. :(

Thnx in advance!!!

thilo
08-26-2009, 01:06 AM
Did you find an answer to your question?

I'm having the same problem several years later ;). I'm using an XMLCollection which is filled with standard XML as dataprovider for the standard Flex Tree control. I want to have, say a structure like this


<node type="folder" name="root" visible="true">
<node type="folder" name="child1" visible="false"/>
<node type="folder" name="child2" visible="true"/>
</node>


to be displayed (or not displayed) according to the visible attribute.

Thanx fellow coders for any ideas, solutions!

natb19
10-06-2009, 06:01 AM
I'm struggling with this also. I can't believe it's so difficult! :confused:

Please, some one, help us!!!

natb19
10-06-2009, 06:44 AM
Ok, I was about to give up and I had an idea... (check the timestamp from my last post, I hard really given up!).

This only stops certain nodes from displaying children (hence the name) not specifying individual nodes, but it solves my immediate problem. I hope it helps/inspires some one else...

package com.nb.common.views
{
import mx.controls.Tree;
import mx.controls.treeClasses.TreeListData;

public class BastardTree extends Tree
{
public function BastardTree()
{
super();
}
/**
*a comma delimited list of node names that wil
* not admit to having children
*/
public var bastardNodes:String = "item";


/**
* Initializes a TreeListData object that is used by the tree item renderer.
*
* @param item The item to be rendered.
* @param treeListData The TreeListDataItem to use in rendering the item.
*/
override protected function initListData(item:Object, treeListData:TreeListData):void
{

super.initListData(item, treeListData);
if (item is XML && this.bastardNodes!="") {
var nodelist:Array = this.bastardNodes.split(",");
var i:XML = item as XML;
for each (var name:String in nodelist){
if (i.localName()==name) {
treeListData.hasChildren = false;
break;

}
}


}
}


}
}