0

I want to add array list (getting from blazeDS) as nodes to tree. And after clicking of particular node, related list is calling from service layer. I have done that but it is not coming as a child node in same tree.

<mx:Tree x="45" y="61" id="tree" change="tree_changeHandler(event)" creationComplete="tree_creationCompleteHandler(event)" dataProvider="{getReporteesResult2.lastResult}" labelField="mgrName" width="409"></mx:Tree>

AS3 code:

below function is showing data as a leaf icon in tree.

protected function tree_creationCompleteHandler(event:FlexEvent):void
        {
            getReporteesResult2.token = managerList.getReportees("rjacoby");

        }

on click of node, service is running and i m getting related data which is under rjacoby too.

protected function tree_changeHandler(event:Event):void
        {
            managerId=event.currentTarget.selectedItem.mgrId;
            Alert.show(managerId);
            getReporteesResult3.token = managerList.getReportees(managerId);

I want these data should be shown as a children of rjacoby with folder icon in same tree. How can i get that. Plz help.

Thanks Rimi

1 Answers1

0

Every node in a Tree has a property called children which is an array. All the child nodes for that node will be inside this property. In your case when you are adding the branch node (rjacoby)to the tree also create one children[] for it. And when the response comes back add your new items to the children[] of that node.

If you want more control you can think of writing a TreeUtility class that would be using some classical algorithms (breadth-search or like) and will help you traverse the whole tree. I wrote one such class for one of such scenarios where Flat data comes from service layer and I need to create hierarchical object which was put inside a Tree.

akhil_mittal
  • 23,309
  • 7
  • 96
  • 95