Creates the groups in ActionScript by using an event handler : Event Handler « Event « Flex






Creates the groups in ActionScript by using an event handler

Creates the groups in ActionScript by using an event handler
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- dpcontrols/adg/SimpleGroupADG.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script> 
         
        import mx.collections.GroupingField; 
        import mx.collections.Grouping; 
        import mx.collections.GroupingCollection2; 
        import mx.collections.ArrayCollection; 
        
        [Bindable] 
        private var dpFlat:ArrayCollection = new ArrayCollection([ 
            {Region:"Southwest", Territory:"Arizona",Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
            {Region:"Southwest", Territory:"Arizona",Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, 
            {Region:"Southwest", Territory:"Central California",Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, 
            {Region:"Southwest", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, 
            {Region:"Southwest", Territory:"Northern California",Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
            {Region:"Southwest", Territory:"Northern California",Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, 
            {Region:"Southwest", Territory:"Southern California",Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
            {Region:"Southwest", Territory:"Southern California",Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000} 
            ]);
        
        [Bindable] 
        public var myGColl:GroupingCollection2 = new GroupingCollection2(); 
        private var myGrp:Grouping = new Grouping(); 
        private function initDG():void { 
            // Initialize the GroupingCollection2 instance. 
            myGColl.source = dpFlat; 
            // The Grouping instance defines the grouping fields 
            // in the collection, and the order of the groups 
            // in the hierarchy. 
            myGrp.fields = [new GroupingField("Region"), new GroupingField("Territory")]; 
            myGrp.label = "Region"; 
            // The grouping property contains a Grouping instance. 
            myGColl.grouping = myGrp; 
            // Specify the GroupedCollection as the data provider for 
            // the AdvancedDataGrid control. 
            myADG.dataProvider=myGColl; 
            // Refresh the display. 
            myGColl.refresh(); 
        } 
      
    </fx:Script>
    <mx:AdvancedDataGrid id="myADG" width="100%"
        height="100%" creationComplete="initDG();">
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="Region" />
            <mx:AdvancedDataGridColumn dataField="Territory" />
            <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                headerText="Territory Rep" />
            <mx:AdvancedDataGridColumn dataField="Actual" />
            <mx:AdvancedDataGridColumn dataField="Estimate" />
        </mx:columns>
    </mx:AdvancedDataGrid>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using event object to make event handlers more genericUsing event object to make event handlers more generic
2.Creating function and use it as event handlerCreating function and use it as event handler
3.A function returning String and use it in button event handlerA function returning String and use it in button event handler
4.Register handler function to Button controlRegister handler function to Button control
5.Remove handlerRemove handler
6.Conditional handlerConditional handler
7.Use the handler property to specify the function Argument StringUse the handler property to specify the function Argument String
8.Use the handlerFunction property to specify the functionUse the handlerFunction property to specify the function
9.Add handlers and then remove handlersAdd handlers and then remove handlers
10.Using ActionScript in MXML event handlersUsing ActionScript in MXML event handlers
11.Specify Event object as a parameter in the event handler functionSpecify Event object as a parameter in the event handler function
12.Define an event handler inline and binds a call to the handler function to the controlDefine an event handler inline and binds a call to the handler function to the control
13.Event handler functionEvent handler function
14.Parent container's click handler disables the target control after the target handles the eventParent container's click handler disables the target control after the target handles the event
15.Handler children clicked event from parent clicked eventHandler children clicked event from parent clicked event
16.Priority parameter and event handler eventPriority parameter and event handler event
17.Add itself to event handlerAdd itself to event handler
18.To use the Event object, you specify it as a parameter in the event handler functionTo use the Event object, you specify it as a parameter in the event handler function
19.Create two event handler functionsCreate two event handler functions
20.Bind a call to the handler function to the control that triggers the eventBind a call to the handler function to the control that triggers the event
21.Simple Event HandlerSimple Event Handler
22.Pass string into event handlerPass string into event handler
23.Use initialize event to register event handlerUse initialize event to register event handler
24.Event handler sequenceEvent handler sequence
25.Use SetEventHandler to set event handler to a targetUse SetEventHandler to set event handler to a target
26.Add SecurityErrorEvent.SECURITY_ERROR event handler
27.Write simple event handler code inlineWrite simple event handler code inline
28.Add event handler to ChangeWatcherAdd event handler to ChangeWatcher
29.Use itemDoubleClick event handler to display HitData informationUse itemDoubleClick event handler to display HitData information
30.Event Object HandlerEvent Object Handler
31.Define variable in click event handlerDefine variable in click event handler
32.Handler result event and fault event for ItemResponderHandler result event and fault event for ItemResponder
33.Using removeEventListener() method to remove event handlerUsing removeEventListener() method to remove event handler
34.Add and remove event handlersAdd and remove event handlers
35.Gets the value of the current target's x, y, and width properties in the focusIn event handler,Gets the value of the current target's x, y, and width properties in the focusIn event handler,
36.Define an event handler for the dragDefine an event handler for the drag