Hierarchical data is data in a structured format where
the data is already arranged in a hierarchy. To display hierarchical
data in the AdvancedDataGrid control,
you set the data provider of the control to an instance of the HierarchicalData
class. The structure of the data in the data provider defines how
the AdvancedDataGrid control displays the data.
Defining hierarchical data with an ArrayCollection
Using an ArrayCollection is
a common way to create hierarchical data, as the following example
shows in the SimpleHierarchicalData.as file. In this example, the
data has three levels – a root level and two child levels:
This example uses the children keyword in the
ArrayCollection definition to define the data hierarchy. The children keyword
is the default keyword used by the HierarchicalData class to define
the hierarchy.
You can use a different keyword to define the hierarchy. The
following example shows the HierarchicalDataCategories.as file,
which uses the categories keyword:
The executing SWF file for the previous example is shown below:
Displaying hierarchical XML data
The examples in the previous section use an ArrayCollection to
populate the AdvancedDataGrid control.
You can also populate the control with hierarchical XML data. The
following example modifies the data from the previous section to format
it as XML, and then passes that data to the AdvancedDataGrid control: