Thanks, Matt, for your answer, which saved me a lot of time. I see the
answer is in the MM flexfaq, but somehow I missed it.
Gary
Message: 13
Date: Wed, 4 Jan 2006 20:56:08 -0800
From: "Matt Chotin" <[EMAIL PROTECTED]>
Subject: RE: Get selected tree node for dynamically created tree
You need to use node.getProperty("label") not .attributes, this way your
code will work regardless of how the dataProvider was specified.
Matt
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ault, Gary - BLS
Sent: Tuesday, January 03, 2006 5:47 AM
To: [email protected]
Subject: [flexcoders] Get selected tree node for dynamically created
tree
First time creating trees in Flex. Can someone explain how to find the
selected tree node on a tree that has a data model created
programmatically? I create my data model as shown below (example from
Flex ActionScript Language Ref 1.5). The tree is displayed correctly.
When I try to use the nodeOpen event on my Tree control, however,
selectedNode is undefined. Event.node.attributes.label and
event.node.attributes.data are also undefined. However, if I use an
mx:XML dataprovider as most tree usage examples do, these attributes are
not undefined.
Code to create model:
var treeDP;
treeDP = new TreeNode();
var root = treeDP.addTreeNode("root","0");
root.addTreeNode("node 1 ","1");
root.addTreeNode("node 2","2");
var node3 = root.addTreeNode("node 3","3");
node3.addTreeNode("node 3-0", "3-0");
node3.addTreeNode("node 3-1", "3-1");
Tree Control:
<mx:Tree id="indTree" dataProvider="{treeDP}" height="100%"
change="treeSelected( event );"
nodeOpen="nodeOpenEvt(event);" ></mx:Tree>
Thanks for any help you can provide,
Gary Ault
Bureau of Labor Statistics
--
--
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/