Gautam,

 

Thanks man!  It helped.  I didn't realize I needed to use the ObjectProxy
and I didn't realize I needed to call itemUpdated.

 

I've got my implementation tied into a web service.  So what I do in the
itemOpenING event is make the Gateway.myMethod.send([args]) call and save
the item in a global, then in the result handler, I loop through my result
set and add them as children to the previously saved "event.item" from
itemOpening(event).  

 

Before I call the Gateway, I check item.children and if count is 0 and
item.isBranch="true", I make the call.

 

My web-service only sends back isBranch="true" when the node has children.

 

I've been hacking on this for at least 5 hours..the Adobe Examples come
close, but not quite.  I'm not sure what I've got is robust.  I'm worried
that a user might click fast and my result handlers could get out of order
because I don't do a good job managing the saving of the event.item value.

 

Jim

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Gautam
Sent: Tuesday, April 17, 2007 9:20 PM
To: [email protected]
Subject: Re: [flexcoders] Lazy-loaded tree examples

 

hi,
hope this helps:

<mx:Tree id="treeSiteList" width="100%" height="78%"
dataProvider="{acSiteTreeList}" iconFunction="myTreeIcon"
itemOpen="setView(event)"/> 

private function setView(event:TreeEvent):void {
                if(event.item.type == "something" && event.item.fetch ==
false) {
                    myEvent = event; //(myEvent is of type TreeEvent) 
                    //update the dataprovider
                    var obj:ObjectProxy;
                var item:Object;
                var children:ArrayCollection;
                for(var i:int = 0; i < acSomething.length; i++) {
                    obj= new ObjectProxy();
                    obj["type"] = "something";
                    obj["children"] = new ArrayCollection();
                    obj["fetch"] = false;
                    item = myEvent.item;
                    children = item.children;
                    item.fetch = true;
                    children.addItem(obj);
                     acSiteTreeList.itemUpdated(item);
                }

                }
            }

fetch is a property i have used in the dataprovider to tell me if I have
fetched the child nodes previously or not...

[Embed(source="../assets/someIcon.png")] 
                 private var reqdIconClass:Class;

private function myTreeIcon(item:Object):Class {
                if(item.type == "something") {
                   return reqdIconClass;
                }else { 
                    return null;
                }
                
            }

                
Regards,
Gautam.



On 3/31/07, Justin Makeig <[EMAIL PROTECTED]> wrote:

Does anyone know of a public Flex 2 implementation of a lazy-loaded tree
that I could 
reference (e.g. loading children dynamically from the server upon expanding
a node)? From 
my searching I've seen a lot of dead ends and frustration, but no solid
examples. I'd hate to 
(clumsily) reinvent the wheel. Any help would be much appreciated.

Justin


 

Reply via email to