R – Flex Get the XML parent of a selected Tree item

apache-flextree

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

Best Answer

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

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