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?
Asked
Active
Viewed 2,549 times
2 Answers
0
Hierarchical data has a childrenField property that you can use to "tell" the control where should it look for branches.
http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_07.html

flexicious.com
- 1,601
- 1
- 13
- 21
-2
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
- 2,446
- 1
- 22
- 27
-
Unless the OP doesn't ask about how to tell the datagrid control where to get the data for the child nodes, which it totally does, I don't see how my answer is wrong. Furthermore, the first column of the AdvancedDataGrid, doesn't "contain" a tree, it provides tree node-like features. – bug-a-lot Mar 01 '12 at 10:53