views:

1478

answers:

1

I have a hierarchical data set that i would like to display in an advancedDataGrid. My data is a set of composed value objects that do not use the 'children' attribute. On a Tree control you can create a custom dataDescriptor to define which elements contain the children of the node. Can this be done on the datagrid as well?

A: 

From Adobe live docs on AdvancedDataGrid examples, you can see that you can set the dataProvider of the AdvancedDataGrid to a GroupingCollection instance, in order to create some groups for your data. Going down the class hierarchy, there is HierarchicalData, which you need to use when setting your dataProvider on the AdvancedDataGrid. Example (sorry for using arrays instead of one XML):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:Array id="dianaSerfes">
     <mx:Object name="geen" surname="zod" />
    </mx:Array>
    <mx:Array id="xySerfs">
     <mx:Object name="sdf" surname="sdfsdgd" />
    </mx:Array>
    <mx:Array id="johnSerfs">
     <mx:Object name="jack" surname="the ripper" />
     <mx:Object name="diana" surname="bloom" serfs="{dianaSerfes}"/>
    </mx:Array>
    <mx:Array id="myData">
     <mx:Object name="xy" surname="zzz" serfs="{xySerfs}" />
     <mx:Object name="blue" surname="zed" />
     <mx:Object name="John" surname="smith" serfs="{johnSerfs}" />
    </mx:Array>
    <mx:AdvancedDataGrid width="100%" height="100%">
     <mx:dataProvider>
      <mx:HierarchicalData id="hd" source="{myData}" childrenField="serfs" />
     </mx:dataProvider>
     <mx:columns>
      <mx:AdvancedDataGridColumn dataField="name" />
      <mx:AdvancedDataGridColumn dataField="surname" />
     </mx:columns>
    </mx:AdvancedDataGrid>
</mx:Application>
bug-a-lot