2 Replies Latest reply on Dec 18, 2009 11:17 PM by udara liyanage

    making a event listner

    udara liyanage

      how to make a event listner to happen when a column in a datagrid is clicked.im using flexbuilder 3,it says that there is n attribute called "cellPress" in dataGrid.

      tjanks in advance.

        • 1. Re: making a event listner
          Gregory Lafrance Level 6

          This code should answer your question.

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance
          www.ChikaraDev.com

          Flex Development and Support Services

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.events.ListEvent;
                import mx.controls.Alert;
                import mx.events.DataGridEvent;
                import mx.collections.ArrayCollection;
                
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                  {fname: "Bob", lname: "Carson"},
                  {fname: "Mary", lname: "Smith"},
                  {fname: "Jim", lname: "Pearson"}
                ]);
                
                private function headerFunc(evt:DataGridEvent):void{
                  mx.controls.Alert.show("Column header " + evt.columnIndex + " (" + evt.dataField + ") clicked.");
                }
                
                private function clickFunc(evt:ListEvent):void{
                  mx.controls.Alert.show("Cell in row " + evt.rowIndex + " column " + evt.columnIndex + " clicked.");        
                }
              ]]>
            </mx:Script>
            <mx:DataGrid id="dg" dataProvider="{ac}" headerRelease="headerFunc(event);"
              itemClick="clickFunc(event);">
              <mx:columns>
                <mx:DataGridColumn dataField="fname" width="100"/>
                <mx:DataGridColumn dataField="lname" width="100"/>
              </mx:columns>
            </mx:DataGrid>
          </mx:Application>
          
          1 person found this helpful
          • 2. Re: making a event listner
            udara liyanage Level 1

            thanks very much for this code,this help me a lot

            im confused in event handlers writing.i have no idea about the arguments that should passed to the event handling function. can you tell me where to find good example/tutorials