3 Replies Latest reply on Dec 21, 2007 10:47 AM by m_hartnett

    Stop the page from refreshing..

    187_2007 Level 1
      I have a tree with about 200 nodes in it. When I click on a parent node that has children I make a call to the backend and retrieve the children associated with the parent node. Upon returning from the backend I do a [insertChildAfter] back into the XML structure. Once that happens I do [myTree.expandChildrenOf()]. which expands the node that I selected.. Works perfectly... BUT, lets say I select a parent node that has children further down the tree.. It retrieves the data, populates the parent node I selected with children, expands everything and then returns me to the top of the page... I don't want to return back to the top. I wanna stay where I am.. Any idea how I can do that? Do you even know what I'm talking about?
        • 1. Stop the page from refreshing..
          m_hartnett Level 3
          I think you need scrollToIndex
          • 2. Re: Stop the page from refreshing..
            187_2007 Level 1
            AH HAAAA... That's what I was looking for... But NOW the question is... How do I get the [int] that goes inside scrollToIndex(int). I tried myTree.selectedIndex... BUT I'm not clicking on a tree node.. In fact, I'm clicking on the ARROW beside the tree note to expand its children.
            • 3. Stop the page from refreshing..
              m_hartnett Level 3
              You will need to use the getChildIndex( item ) method.
              Once you get the index then you can scrollToIndex method.

              I also believe you might need to execute a myTree.validateNow() method after the scrollToIndex is done.
              Not sure if this is really needed but if you see strange results after the scroll then try the validateNow.

              Almost every Flex object that is based on a list and generates scroll bars has the getChildIndex and scrollToIndex.
              If you were to put the tree or a tileList in a VBox and relied on the VBox scrollbars then you would not have this ability to scroll to view. It is more work.

              good luck