0
votes

I'm using AdvancedDataGrid in flex with the following structure:

 - A
  - AA
     - AAA
     - AAB
  - AB
     - ABA
     - ABB
 - B
  - BA
     - BAA
     - BAB
  - BB
     - BBA
     - BBB

I want to implement a function in actionscript, which expand only one level of the tree.

E.g.: When I call the function at the following state,

 + A
 + B

I will get this:

 - A
  + AA
  + AB
 - B
  + BA
  + BB

When I call it again, I will see the whole tree.

I tried to use the expandItem() method of AdvancedDatagrid, but I have no idea how to list the nodes. Can someone write me a sample code?

Thanks for your help!

1

1 Answers

1
votes

Assuming your data is already hierarchical, you can simply do an iteration through your dataProvider and call expandItem on each one.

private function onClick(event:MouseEvent):void
{
    for each(var o:Object in grid.dataProvider)
    {
        grid.expandItem(o);
    }
}