Adobe Dreamweaver Forums



Last 10 THreads :         problems linking PDFs (Last Post : Alan - Replies : 1 - Views : 2 )           »          Changing RadioButton Label (Last Post : justintoflex - Replies : 2 - Views : 5 )           »          Table Borders MIssing in JavaHelp (Last Post : soxmann - Replies : 3 - Views : 8 )           »          Clock .getUTC not working (Last Post : bolszo - Replies : 2 - Views : 3 )           »          cfimage error (Last Post : masoud_amen - Replies : 2 - Views : 3 )           »          Dragging components (Last Post : hsfrey - Replies : 2 - Views : 4 )           »          Is file too large? (Last Post : tweaked_eye - Replies : 0 - Views : 1 )           »          Could not find the included template (Last Post : azuro28 - Replies : 2 - Views : 3 )           »          flash loader reappears after movie plays (Last Post : lyshamo - Replies : 3 - Views : 4 )           »          How to turn IMAGE into MOVIECLIP??? (Last Post : Snufferson - Replies : 7 - Views : 8 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-03-2008, 10:03 PM
FrankyG813
 
Posts: n/a
Diggs:
Default How to Expand All Nodes on Tree

I found examples of this but I'm having a hard time figuring out why it does
not work.
Here's my code..Any help appreciated.

My function;
private function expandTreeNodes():void{
var projectParts:XML = treLinks.dataProvider[0];
treLinks.openItems = projectParts..node;
/* I even tried the code below to no avail
** for each (var item:XML in projectParts..node){
** treLinks.expandItem(item, true);
** }
*/
}
My dataprovider for the tree;
<mx:XMLListCollection id="projectParts">
<mx:XMLList>
<node label="Product" data="100">
<node label="Part A" data="70"/>
<node label="Part B" data="10">
<node label="Component a" data="2"/>
<node label="Component b" data="3"/>
<node label="Component c" data="0" isBranch="true" />
<node label="Component d" data="5" />
</node>
<node label="Part C" data="15"/>
<node label="Part D" data="5"/>
</node>
</mx:XMLList>
</mx:XMLListCollection>
My Tree:
<mx:Tree id="treLinks" x="10" y="10" width="680" height="298" fontSize="10"
labelField="@label" dataProvider="{projectParts}"
creationComplete="expandTreeNodes()" />



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-04-2008, 06:04 AM
gallaharsha
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Hi,
I dont understand the purpose of this line:
var projectParts:XML = treLinks.dataProvider[0];

remove that and try this..




Reply With Quote
  #3 (permalink)  
Old 12-04-2008, 04:23 PM
FrankyG813
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

If I comment out the line, then I get a compilation error;

Access of possibly undefined property node through a reference with static type mx.collections:XMLListCollection.

Reply With Quote


  #4 (permalink)  
Old 12-05-2008, 06:15 AM
gallaharsha
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Hi,
Firstly the error you were getting is because you cant apply all that you
apply on XML object to XMLListCollection. In order to do it you need to iterate
over all XML objects in the XMLListCollection and then apply.Hope you got it.
Here is the working code attached. Any doubts do reply.

private function expandTreeNodes():void{
for each(var item in projectParts){
treLinks.openItems = item.node;
}
}

Reply With Quote
  #5 (permalink)  
Old 12-05-2008, 04:03 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Hey guys,
FrankieG813, if you are just trying to expand all of your tree branches and
their children when the app first loads,
do this:

private function expandTreeNodes():void{
treLinks.expandChildrenOf(projectParts[0],true);
}

You don't use openItems to expand tree branches, you use either
expandChildrenOf() or expandItem().
Since you really only have one top-level node, I just used expandChildrenOf()
on that, and all its children open up.

Reply With Quote
  #6 (permalink)  
Old 12-05-2008, 04:33 PM
FrankyG813
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Thanks so much for your help. FYI, I first tried GallaHarsha's change and it
did not work. It also gave me a warning about item not having a declaration.
I tried rtalton's solution and it works. My next question would be how would I
handle this if there were multiple top level nodes.

Thanks

Frank

Reply With Quote


  #7 (permalink)  
Old 12-05-2008, 05:53 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Just wanted to clarify: gallaharsha's solution should work but I have better
results with this way... didn't mean any offense to gallaharsha.

Try this to open multiple tree branches. It uses a for loop and goes to each
top-level node and calls expandChildrenOf(). Look below for the XML I'm using
(it's based on yours, but with one more node appended to it).

Be sure you read the help docs for more detail on the Tree control:

http://livedocs.adobe.com/flex/3/lan...ee.html&mx/con
trols/class-list.html


private function expandTreeNodes():void{
//treLinks.expandChildrenOf(projectParts[0],true);//WORKS FOR A SINGLE
NODE ONLY.
for (var i:int = 0; i < treLinks.dataProvider.length; ++i){
treLinks.expandChildrenOf(projectParts[i],true)
}
}

<mx:XMLListCollection id="projectParts">
<mx:XMLList >
<node label="Product" data="100">
<node label="Part A" data="70"/>
<node label="Part B" data="10">
<node label="Component a" data="2"/>
<node label="Component b" data="3"/>
<node label="Component c" data="0" isBranch="true" />
<node label="Component d" data="5" />
</node>
<node label="Part C" data="15"/>
<node label="Part D" data="5"/>
</node>
<node label="Suppliers" data="100">
<node label="ACME Fireworks" data="70"/>
<node label="Wily Coyote Bomb Parts" data="70"/>
<node label="Road Runner Shoe Supply" data="70"/>
</node>
</mx:XMLList>
</mx:XMLListCollection>

Reply With Quote
  #8 (permalink)  
Old 12-05-2008, 09:42 PM
FrankyG813
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

No offense meant towards gallaharsha either. I just wanted to alert him/her
that there were compilation errors and what was suggested did not work. I
really do appreciate any suggestions.

I tried your solution for the single node and it worked, however when I tried
to implement the multi node solution it did not work. When I un-remarked the
line that says WORKS FOR SINGLE NODE ONLY, sure enough, it expanded the nodes,
but only on the first node.

Now I'm confused.

Reply With Quote
  #9 (permalink)  
Old 12-05-2008, 09:52 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

The code got posted incorrectly, sorry.
Change this line:
treLinks.expandChildrenOf(projectParts,true)
To:
treLinks.expandChildrenOf(projectParts[i],true)

The "[i]" is a reference inside the loop to the node# being operated upon. In
each loop, "i" increments (0,1,2,3,etc).
So you can read this line as in treLinks, expand all the children of node #1
in projectParts.
Look up the expandChildrenOf() method and make sure you understand what's
going on. This will help you when you're debugging you app.
Have fun!

Reply With Quote


  #10 (permalink)  
Old 12-05-2008, 10:02 PM
FrankyG813
 
Posts: n/a
Diggs:
Default Re: How to Expand All Nodes on Tree

Sorry, but I don't see any changes to this line other than the fact that true
is italicized on the post. Below is what I see....

Change this line:
treLinks.expandChildrenOf(projectParts,true)
To:
treLinks.expandChildrenOf(projectParts,true)

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk