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


    Zolotoj Level 3

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

      Here is my code:



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


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


      Any help?



        • 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.