Markus
Markus

Reputation: 4038

Flex Get the XML parent of a selected Tree item

I have a XML based Tree Control. The XML Structure is recursive, so the children's can have the same Element as the parent. I now want to let the user add and remove the elements. Do do so I need to get the parent element of the selected Item. Following code I already collected together:

var selected:XML = treeControl.selectedItem;
parent.insertChildAfter(selected:XML, newElement);

I just don't know how to get to the selected parents node as there is no such method like treeControl.selectedItem.parent...

Thanks for any hint! Markus

Upvotes: 2

Views: 3714

Answers (1)

Christophe Herreman
Christophe Herreman

Reputation: 16085

You can do this with the parent() method on the XML object.

var parent:XML = XML(treeControl.selectedItem).parent();

Upvotes: 4

Related Questions