Hi sarkar,

Try this approach...

//Call this function on tree load complete event.

//Expand all the nodes by taking the tree's dataprovider
//first expand the root node
//Then expand the child nodes

        public function expandAllNodes():void
        {
             for(var i:int = 0; i < this.dataProvider.length; i++)
            {
                this.expandItem(this.dataProvider[i], true);
                expandNodes(this.dataProvider[i]);
            }
        }

        private    function expandEachNode(treeXML:XML):void
        {
            for each(var xmlElement:XML in treeXML.children())
            {
                this.expandItem(xmlElement, true);
                if(xmlElement.children().length() > 0)
                {
                    expandNodes(xmlElement);
                }
              }
        }


On Fri, Apr 1, 2011 at 7:26 PM, abhik sarkar <[email protected]>wrote:

> Thanks for the reply.
>
> What I actually wanted is to get it done while the tree is loaded.
>
> I have done it for the case when the tree is already loaded .
>
>
>
> On Fri, Apr 1, 2011 at 6:39 PM, Kronos <[email protected]> wrote:
>
>> Initially the tree always loads collapsed. So what u need to do is
>> select the first node (root node) & expand it
>>
>> tree.selectedIndex = 0
>> tree.expandItem(tree.selectedItem,true);
>>
>> Then u need to move to the child node that u need to expand
>>
>> tree.selectedIndex = x ( where x is the child node that needs to be
>> expanded)
>>
>> then repeat the above code
>> tree.expandItem(tree.selectedItem,true);
>>
>> Now u can move to the leaf node that u want selected by
>>
>> tree.selectedIndex = x + i ( where i is the relative position of the
>> leaf node from its parent x)
>>
>> That should do it.
>>
>> Also note that if multiple nodes are open and u wish to do to a
>> particular leaf node then u need to set the selected index value as
>> the number of open nodes in the tree considering all open nodes.
>>
>> For eg: If in my tree my 2nd child node is open & it has 2 leaf nodes
>> then if i want to go to the 3rd child node then the selected index
>> value should be set to 5 (3 + 2) & not just 3. But dont ask me how ur
>> gonna dynamically count how many nodes are open bcoz i havent figured
>> that out up till now :(
>>
>> Enjoy.
>>
>>
>> On Apr 1, 4:27 pm, "[email protected]"
>> <[email protected]> wrote:
>> > I have a requirement where I have to load a Tree Hierarchy with a
>> > particular node expanded and in the expanded node a particular leaf
>> > pre selected.
>> >
>> > Any idea/code regarding this would be helpful.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Flex India Community" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/flex_india?hl=en.
>>
>>
>
>
> --
> Thanks
> Abhik Sarkar
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>



-- 

Regards,
Manikandan.S  <http://www.umoldit.com>
 <http://www.umoldit.com>

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to