2 Replies Latest reply on Aug 23, 2006 8:55 AM by krisk58

    three add branch keep other branches open

    krisk58
      Friends

      can i incrementaly build the three, but keep the open nodes open.

      now:
      1) i click on the branch and add additional information to dataprovider object
      2) i open the branch and see my just loaded data displayed

      3) I click on other root branch and it is loaded
      but my aloready open branch is closed and three seems to be redraw, the moment underling datasource object is
      refreshed:

      <mx:dataProvider>
      {ModelLocator.folderVOA.dispfolders}
      </mx:dataProvider>

      Can I avoid cloasing any proviously open branches?

      thank you

        • 1. Re: three add branch keep other branches open
          ntsiii Level 3
          Assigning the dataProvider will always cause the tree to be completely re-rendered, and will initialize the nodes to their default disclosure state.

          You have two options in 1.5 (2.0 makes this much easier):
          1. Keep track of the open status of the nodes, by storing some key that will identify that node. After the tree is re-rendered, recursively travel every node, searching for the open branches. When you find one, climb back up the tree, opening each node as yo go until you reach the root. If you are careful you can make this pretty efficient, because you only need to store-restore the open state of the last open node in the branch, since all of its parents must be also open.

          2. Do not re-assign the dataprovider. Instead use the dataProvider methods to update the dataProvider. This should make the tree respond visually, without completely re-rendering. This might be more difficult.

          Since I only needed to restore a single, selected node, I used the first option. The second would be much more efficient and long term flexible if you can make it work.

          In flex 2.0, you just save the array "selectedItems", then assign that array back to selectedItems to restore the state. Cool, huh?

          Tracy
          • 2. Re: three add branch keep other branches open
            krisk58 Level 1
            Tracy

            thank you very much for help. sometimes to know you can not do somthing is as helpful as knowing how to do it!

            i my try to go with my own seletedItems structure, so i can reopen opened brunches.

            we are stuck with 1.5 as my boss said :-( - 2 2 big a change, uncharted grounds...

            thanks again

            P.S three = 3 not a tree and i am sorry for mistake