yes.  this was one of the first things Ilearned to do in Flex...abit
back.  I'm planning on blogging it when I get some free time.  Belowis
some code to do this.  The webservice call below fectched children to
the node clicked on when a user clicked the arrow to drill down in the
tree.  It worked well using our people soft tree of about 20,000
employees.  This line

var node = locTree.addTreeNode('the big boss','123456789');

was hardcoded representing the pres of the company, ok to hardocde as
this position changes very rarely.


 HTH


<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>

        <mx:Script>
                <![CDATA[
                import mx.controls.treeclasses.*;
                var selectedNode:Object;
                var getPosnbr:String;
                var chosenNode:Object;  
                
                function drill(event):Void      {
                        if(selectedNode.getProperty('done') == false)   {
                                var RS = myWS.getDirectReports.result;
                                for( var i = 0; i < RS.length; i++ )    {
                                        var newNode = 
selectedNode.addTreeNode(RS[i].NAME, RS[i].POSNBR);
                                        if(RS[i].SUBCNT > 0)
                                                
newNode.setProperty('isBranch',true);
                                        else
                                                
newNode.setProperty('isBranch',false);
                                        newNode.setProperty('done', false);
                                }
                                selectedNode.setProperty('done',true);
                                
myTree.setIsOpen(selectedNode,false,false,false);
                                myTree.setIsOpen(selectedNode,true,false,false);
                        }
                }
                
                function initPage():Void        {
                        var locTree= new TreeNode();
                        var node = locTree.addTreeNode('the big 
boss','123456789');
                        locTree.setIsBranch(node,true);
                        node.setProperty('done',false);
                        node.setProperty('isBranch',true);
                        myTree.dataProvider = locTree;
                        myTree.setIsOpen(0,true,false,false);
                }
                ]]>
        </mx:Script>
        
        <mx:WebService id="myWS"
wsdl="http://foo.com/douglasknudsen/flex/flex.cfc?wsdl";
showBusyCursor="true" fault="alert('Error: ' +
event.fault.faultstring,'Error')">
                <mx:operation name="getDirectReports" result="drill()" >
                        <mx:request>
                                <posnbr>{getPosnbr}</posnbr>
                        </mx:request>
                </mx:operation>
        </mx:WebService>
        
        <mx:Panel id="main" title="Flex Sample" width="100%" height="100%">
                <mx:HBox backgroundColor="#FFFFFF" width="100%" height="100%"
horizontalGap="30">
                
                        <mx:Tree id="myTree" initialize="initPage()"  
width="300"
height="400" change="chosenNode = event.target.selectedItem"
nodeOpen="selectedNode =
event.node;getPosnbr=selectedNode.getProperty('data');
myWS.getDirectReports.send();"  >
                                
                        </mx:Tree>
                
                        <mx:VBox width="200">
                                <mx:Label text="Selected label: 
{chosenNode.getProperty('label')}"/>
                                <mx:Label text="Selected data: 
{chosenNode.getProperty('data')}"/>
                        </mx:VBox>
                
                </mx:HBox>
        </mx:Panel>

</mx:Application>


DK


On 8/4/05, Shahnavaz Alware <[EMAIL PROTECTED]> wrote:
>  
>  
> 
> Hi, 
> 
>   
> 
> I have huge collection of VO's which I want to present using tree control
> (approx 8000 nodes). For better user experience performance I am planning to
> get only top nodes initially and after that with every node click I will get
> one level down children nodes. This means I will have to add the children
> nodes to the tree dynamically at some specified parent node. Is this
> possible? What is the best way to load huge tree? I have not used tree
> control before with flex so not too familiar with it, so any inputs, ideas,
> comments on this will be appreciated. 
> 
>   
> 
>   
> 
> Thanks, 
> 
>   
> 
> Shahnavaz 
> 
>  --
>  Flexcoders Mailing List
>  FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>  Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> 
>  
>  
>  ________________________________
>  YAHOO! GROUPS LINKS 
>  
>  
>  Visit your group "flexcoders" on the web.
>   
>  To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  
>  ________________________________
>  


-- 
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hdlqmra/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123193225/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to