4 Replies Latest reply on Sep 2, 2007 11:32 PM by ThinkingProspects

    Tree calculateDropIndex problem

      Hi there

      i know this problem was present before. Today i ran in exactly this problem and want to ask, if somebody already has a solution for this. For easyer explanation i made a screenshot of the problem part.

      The Problem

      The little Screeny shows a textinput at the top, which is displaying the actual drag over node label in the tree.
      If i drag a node under the last child of a folder, the line will appear, which is telling me that i can add the selected node after this last node as sibling. But calculateDropIndex dont calculates the correct index of the dragOver Node. Instead it calculates the index of the parent().sibling after the parentNode. This is not a problem as long as you dont want to update the new position of the dragged node in a database. I tryed a few things and googled for mayb 4 hours but found no adorable solution for this problem.

      Does anybody have a good solution to fix this? Or do we have to wait and hope until Flex3 ?

      Thank you guys and have a good day
      ICQ #38561935
        • 1. Re: Tree calculateDropIndex problem
          ThinkingProspects Level 1

          I faced the similar problem, and finally had a work around for that. See if that helps to you. It may not be the best of the solution.
          So problem is that tree does not validate itself to and hence fails to calculate the dropindex.
          I reset the dataprovider, and again expanded the tree.
          • 2. Tree calculateDropIndex problem
            mike77ch Level 1
            Hi ThinkingProspects

            Thank you for your approach.
            The Problem is, that my dataProvider is an XMLListCollection with 1500 categories loaded from a remote-server. So i dont know if this solution will work for me but i will surely test it.

            Best Regards

            Edit: At which point of your drag and drop action do you reset the dataProvider?
            Have you got maybe a simple file or code snippet for that?
            • 3. Re: Tree calculateDropIndex problem
              ThinkingProspects Level 1
              Hi Mike,

              Apologies for the delay due to weekends.

              public function reset():void

              /* reset the provider */
              dataTree.dataProvider = dataManager.getDataModelArray();

              /* set the root as selected, please note that selectedIndex i more reliable than selectedItem (from one of the flex authors, I believe */
              dataTree.selectedIndex = 0;
              dataManager.setSelectedDataNode(DataNode(dataTree.selectedItem)); // expand it DataNode is my class

              • 4. Re: Tree calculateDropIndex problem
                ThinkingProspects Level 1
                Calling code is like this


                As I wanted the same Item to be shown as selected, which was selected before resetting the dataprovider