If you are using e4x, the descendants() method will return an XMLList of
all the, well, descendants.

With this, you would not need to recurse, but could set the checked
value in a loop on the XMLList.

 

Note, for this to work correctly, you must set a value on the
dataProvider, and have the renderer read this value to set the check-box
state.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of vuleman
Sent: Monday, January 22, 2007 9:52 PM
To: [email protected]
Subject: [flexcoders] Custom Tree Renderer with checkboxes for Flex 2

 

Hi,
I'm writing a custom tree renderer to include a checkbox for each 
tree node. I want to code inside the renderer itself so that when a 
node's checkbox is selected, all the children's checkboxes should 
also be selected. It looks something like this:

override protected function createChildren ()
{
...
checkbox = new CheckBox();
checkbox.addEventListener (MouseEvent.CLICK, handleClick);
...
}

private function handleClick (event:MouseEvent)
{
var checked:Boolean = checkbox.selected;
processClick (this, checked);
}

private function processClick (currRenderer, checked)
{
foreach child {
processClick (currRenderer.child, checked);
}
}

The problem is i'm not sure what to be passed to processClick(). I'm 
looking for a some variables that let me traverse from that node down 
to all the child. In Flex 1.5, you can use "item" which is the 
current node. Is there a similar variables in Flex 2?
Thank you
Vu

 

Reply via email to