By lazy loading, I assume that you want to add data dynamically into a
tree, depending on the actions of a user.

In my case I have a tree with the following levels:

category / group / brand / size / sku

On starting the app I load in one go from XML  all the data down to brand:

  import flash.events.*;
  import mx.rpc.events.*;
  import mx.events.*;
  import mx.controls.*;

  [Bindable] public var openedNode:Object;
  [Bindable] public var productData:XML = new XML();

  public var productFragment:XML;

  public function productsData(event:ResultEvent) : void {
    productData = XML(event.result);
    for each (var prop:XML in productData.category) {
      for each (var propX:XML in prop.group) {
        for each (var propY:XML in propX.brand) {
          [EMAIL PROTECTED] = "true";
          [EMAIL PROTECTED]"false"
        }
      }
    }
  }

In my app when the user gets to the brand level, I want the tree to
display that it is a branch, even though the dataprovider does not
have any data below brand, that is why I set the attribute isBranch.
The attribute fetchDone, tells me that no data yet exists below the brand.

When the user clicks on a brand node to expand:

on the itemOpen event:

  private function treeNodeOpen(event:TreeEvent):void {
    openedNode = event.item;
    if (openedNode.name().toString() == "brand") {
      if ([EMAIL PROTECTED]"false") {
        openedNode = openedNode.setChildren(productFragment);
        [EMAIL PROTECTED]"true"
      }
    }
  }

The code to set the fragment of extra data is:

  public function productsFragment(event:ResultEvent) : void {
    productFragment = new XML(event.result);
  }

At the moment, my example is work in progress and has the fragment of
data in an xml file, which is loaded at the begining of the app. In a
real case, it would come from a db, which would mean that the itemOpen
event would send a request for the data, and the request result
handler would actually put it in the tree. Also your request for data,
would need to provide the parameters so that the appropriate data was
returned.

Hope this gives you some ideas on how to proceed. I did something
similar in Flex1.5, and it is in production, and works very well and
fast. Though in 1.5 I did not use XML, but used remote objects, and
my granularity was 1 level, so for each level opened, it would only
get the data for that immediate level below.

Andrew


--- In flexcoders@yahoogroups.com, "box110a" <[EMAIL PROTECTED]>
wrote:
>
> Has anybody had any luck lazy loading a Tree? I've tried implementing
> an ITreeDataDescriptor with no luck. The Documentation seems to be out
> of date.
>
> The implementation could be with xml or FDS Java-adaptor.
>
> thanks,
> JB
>






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




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to