3 Replies Latest reply on Aug 25, 2006 11:58 AM by ntsiii

    Tree selected Index

      I have a tree control using XMLListCollection as the dataprovider. I have a delete button, when clicked should delete the selected tree item.

      However, I am unable to get the index of the item selected to call removeItemAt(index). I would greatly appreciate any help.

        • 1. Re: Tree selected Index
          deepa subramaniam (adobe)
          selectedIndex is the property that keeps track of the index of the selected item in any List-based control. Try:


          • 2. Re: Tree selected Index
            opensource_linux Level 1
            Deepa Thanks for your response. I tried what you suggested but I keep getting out of Range errors.

            I have a hierarchical XMLListCollection:

            <Captials label="US State Capitals">
            <capital label="Al" value="Montgomery0"/>
            <capital label="Ak" value="Montgomery1"/>
            <capital label="Ar" value="Montgomery2"/>
            <capital label="At" value="Montgomery3"/>
            <capital label="Ap" value="Montgomery4"/>
            <Captials label="something" />

            The tree controls display's it properly. When I open the tree item it displays the child nodes. When I select the one of the subtree item and click delete, I get Out of Range error.

            One thing I noticed was that the selectedIndex changes depending upon whether the item with children is open or close. if its open the children take the next index. If its closed, the next tree item gets the index.

            Not sure how to go about deleting child nodes correctly.

            • 3. Re: Tree selected Index
              ntsiii Level 3
              Deleting an item causes the indexs to change. Try saving the selectedIndex in a variable, then using that in the removeItemAt() method.