Using nested data in an ArrayCollection to display hierarchically
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
[Bindable]
public var myAC:ArrayCollection = new ArrayCollection([
{
name:'Friends', children:[
{name:'A', email:'a@domain.com'},
{name:'B', email:'b@domain.com'},
{name:'C', email:'c@domain.com'}]},
{name:'Family', children:[
{name:'Z', email:'z@domain.com'},
{name:'S', email:'s@domain.com'}]
}]);
</mx:Script>
<mx:HierarchicalData source="{myAC}" id="myHD" />
<mx:AdvancedDataGrid dataProvider="{myHD}" width="300">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="name" headerText="Contacts" />
<mx:AdvancedDataGridColumn dataField="email" headerText="Email" />
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>
Related examples in the same category