2 Replies Latest reply on May 12, 2010 11:21 AM by dan.biran

    mx Tree how do I expand when not using an XML data provider


      I have a tree control that is bound its dataProvider to an object structure that relates to a tree quite well for navigation (roots have children and those children have children) however the tree control it seems cannot expand items from code after doing this. Unless I change all my objects to be sourced from an XML data provider. There seems to be a lack of examples of tree controls using anything but XML data providers.


      I need to be able to use the array of objects I bound the control to in order to expand certain elements in the tree. However it seems when I do this the UI throws an exception so hard the IDE has no clue where the call stack went until I continue execution.


      How can I call expandItem w/o having the XML Data provider? What object do I pass it?


      I tried this but it does not work:


      classTree.expandItem((classTree.dataProvider[0] as Object), true);




        • 1. Re: mx Tree how do I expand when not using an XML data provider
          TeotiGraphix Level 3





          Are you sure that the object you are passing to the expandItem() method is correct?


          The mx:Tree definitly works with Object/ArrayCollection strctures, and does indeed expand and collapse them.


          I am thinking you are not passing the correct reference.



          • 2. Re: mx Tree how do I expand when not using an XML data provider
            dan.biran Level 1

            Yes I am passing the same reference. I'll try to dig deeper today to see what else could be causing this


            Just verified again the memory reference between my collection and the object in the event handler are the exact same memory address yet when the node is expanded via mouse it works but from code no.


            It seems inside the expandItem the iterator is always null when attempting to expand from code. Ok I dug deeper the trees are different this seems to be a problem with mate not using the caching correctly.


            I now have to find another way to send an event from the viewmodel to the view programmatically.