views:

421

answers:

2

I have a Flex tree with an ArrayCollection as data provider. The collection holds an array of CategoryVO objects. Each object can have another array of CategoryVO objects inside it's "child" attribute. This way the tree displays the data correctly.

Now I want to get the parent of a specific item, e.g. tree.selectedItem. Using XML as data provider the item parent is avaiable thorugh the parent() method. But I can't convert my data to XML. How can I get an item's parent? Perphaps using the tree's dataDescriptor?

A: 

The DataDescriptor does not contain parent information.

The easiest solution I believe would be simply adding a reference to the parent in each CategoryVO object.

CookieOfFortune
That's what im already doing. But I have dragMoveEnabled in the tree and when an item is moved, I need to find out the new parent.
Thomas
+2  A: 

I just found out how to solve my problem :) The tree offers a getParentItem(item:Object) method that returns the parent item of the item. Notice that this function returns null for top level items.

Thomas