Make sure you’re using the TreeDataProvider methods which means selectedItem.getProperty(“data”), not .attributes (since that will only work for XML and not when you use an object graph).

 

Matt

 


From: Ted Casey [mailto:[EMAIL PROTECTED]
Sent: Monday, March 28, 2005 9:51 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Weird tree issue

 

Are you using attributes.data?  For example:

<?xml version="1.0" encoding="iso-8859-1" ?>

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

<mx:XML id="myXML">
      <node label="FirstNode" data="">
            <node label="FirstSubNode" data="">
      </node>
      <node label="SecondNode" data="">
</mx:XML>

<mx:Tree id="myTree" dataProvider="{myXML}"/>

<mx:TextInput id="myText"/>

<mx:Button label="click me"
click="myText.text=myTree.selectedItem.attributes.data"/>

</mx:Application>


Thanks,

Ted

-----Original Message-----
From: cazzaran [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 27, 2005 1:35 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Weird tree issue



I have a tree I'm populating with objects that mimic my serverside
Group classes. What's happening is that the tree is getting built, but
the data field of the nodes isn't getting filled.

This method:
var node = treeDP.addTreeNode(group.name, group);

is supposed to create a node with the label of the group's name, and
the group object itself as the data. Problem is, while the tree gets
populated, and you can see the nodes with labels, the actual group
isn't there in the data field. Obviously the group is getting
instantiated, because the tree nodes have labels... Any reason why
this shouldn't work?

I'm new to Flex, and AS, but this seems like it should work.

Below is the code I use to fill my tree...

var treeDP;     
public function initGroupTree() {
      user = mx.core.Application.application.user;
      var topGroups:Array = user.organization.onlyTopSuperGroups;
      treeDP = new TreeNode();
      for(var i in topGroups) {
            var group:Group = topGroups[i];
            var node = treeDP.addTreeNode(group.name, group);
            addSubGroupsToTree(node, group);
      }
      groupTree.dataProvider = treeDP;
}

private function addSubGroupsToTree(node, group:Group):Void {
      var subGroups:Array = group.subGroups;
      for(var i in subGroups) {
            var group:Group = subGroups[i];
            var subNode = node.addTreeNode(group.name, group);
            addSubGroupsToTree(subNode, group);
      }
}






Yahoo! Groups Links










Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to