1 Reply Latest reply on Oct 29, 2009 12:19 PM by paul.williams

    collectionChange

    Zolotoj Level 3

      I am trying to catch collectionChange when a new row is selected.

      Here is my code:

       

      dataGridAddNewRow.mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:DataGrid xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      xmlns:mx="library://ns.adobe.com/flex/halo">
           <fx:Script>      
                <![CDATA[
                     import mx.events.CollectionEvent;
                     private function init():void
                     {
                          dataProvider.addEventListener("collectionChange", addNewRow);
                     }
                     private function addNewRow(event:CollectionEvent):void
                     {
                          trace(event);
                     }
                ]]>   
           </fx:Script>          
      </mx:DataGrid>
      
      
      <modulecode:dataGridAddNewRow id="fields" width="30%" height="100%">
           <modulecode:columns>
                     <mx:DataGridColumn dataField="fldname" headerText="Field Name" textAlign="left"/>
           </modulecode:columns>
      </modulecode:dataGridAddNewRow>     
       
                          
      
       
      

       

      After dataProvider is set, and a row is changed no traces are shown.

       

      Any help?

       

      Thanks

        • 1. Re: collectionChange
          paul.williams Level 4

          Datagrid already has a protected method that is called in response to a CollectionChange event. So if you are extending DataGrid you can just override that:

           

          override protected function collectionChangeHandler(event:Event):void
          {

               super.collectionChangeHandler( event );

           

               trace( "Collection changed" );

          }

           

          Note that CollectionChange events are dispatched when the contents of a collection change. Selecting a row in a DataGrid does not cause the dataprovider's contents to change, so I wouldn't expect to see a CollectionChange event from this action.