Regrouping AdvancedDataGrid
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:VBox width="400" height="300" creationComplete="init()">
<mx:Script>
import mx.collections.Grouping;
import mx.collections.GroupingField;
import mx.collections.GroupingCollection2;
[Bindable]
private var groupingColl:GroupingCollection2;
private function init():void {
groupingColl = new GroupingCollection2();
groupingColl.source = [{city:"A", state:"C",region:"E"},
{city:"B",state:"D", region:"S"}];
var groupingInst:Grouping = new Grouping();
groupingInst.fields = [new GroupingField("state")];
groupingColl.grouping = groupingInst;
groupingColl.refresh(false);
// create Column1 Grouping()
groupingInst = new Grouping();
groupingInst.fields = [new GroupingField("region")];
groupingColl.grouping = groupingInst;
groupingColl.refresh(false);
}
</mx:Script>
<mx:AdvancedDataGrid dataProvider="{groupingColl}">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="city"/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:VBox>
</mx:Application>
Related examples in the same category