Regroup GroupCollection : AdvancedDataGridColumn « Grid « Flex






Regroup GroupCollection

Regroup GroupCollection
          
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:s="library://ns.adobe.com/flex/spark"
    creationComplete="handleCreationComplete();">
    
    <mx:GroupingCollection2 id="groupingCollection">
            <mx:source>
                <mx:Object city="A" state="C" region="E" />
                <mx:Object city="B" state="D" region="F" />
            </mx:source>
            <mx:grouping>
                <mx:Grouping>
                    <mx:GroupingField name="state" />
                </mx:Grouping>
            </mx:grouping>
    </mx:GroupingCollection2>
    
    <mx:Script>
        
            import mx.collections.Grouping;
            import mx.collections.GroupingField;
            
            private function handleCreationComplete():void
            {
                groupingCollection.refresh();
            }
            
            private function createGrouping( field:String ):void 
            {
                var groupingInst:Grouping = new Grouping();
                groupingInst.fields = [new GroupingField( field )];
                groupingCollection.grouping = groupingInst;
                groupingCollection.refresh(false);
            }

      
    </mx:Script>

    <mx:AdvancedDataGrid id="grid" dataProvider="{groupingCollection}">
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="city" />
            <mx:AdvancedDataGridColumn dataField="state" />
            <mx:AdvancedDataGridColumn dataField="region" />
        </mx:columns>
    </mx:AdvancedDataGrid>
    <mx:Button label="region group" click="{createGrouping('region')}" />
    
</mx:Application>

   
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.AdvancedDataGridColumn for the GroupLabel fieldAdvancedDataGridColumn for the GroupLabel field
2.Add multiple groups to the controlAdd multiple groups to the control
3.AdvancedDataGridColumn inside ColumnsAdvancedDataGridColumn inside Columns
4.Set default leaf icon to null to hide itSet default leaf icon to null to hide it
5.Custom icons for the folder open and closed iconsCustom icons for the folder open and closed icons
6.Use groupedColumns component to group columns togetherUse groupedColumns component to group columns together
7.Create the column groupingCreate the column grouping
8.Multiple column sort when the sortExpertMode property is set to trueMultiple column sort when the sortExpertMode property is set to true
9.Add groups named Area and RevenuesAdd groups named Area and Revenues
10.Column Grouping for Hierarchical DataColumn Grouping for Hierarchical Data