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 available through the parent() method. But I can't convert my data to XML. How can I get an item's parent? Perhaps using the tree's dataDescriptor?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Thomas Müller
  • 1,433
  • 11
  • 24

2 Answers2

7

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 Müller
  • 1,433
  • 11
  • 24
0

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
  • 13,836
  • 8
  • 42
  • 58
  • 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 Müller Jan 11 '10 at 19:48