flex4advanceddatagrid

Listening for dataChange event in AdvancedDataGrid


This is my code:

<controls:AdvancedDataGrid id="adg" dataChange="adg_dataChangeHandler(event)">
      <!-- other stuff goes here -->
</controls:AdvancedDataGrid>

and in my ActionScript code:

protected function adg_dataChangeHandler(event:FlexEvent):void
{
  trace(1);
}

When I edit a cell in advancedDataGrid (making the columns editable of course) it never dispatches an event. Or, in other words, my function is never called. How can I fix this?


Solution

  • I think that the better option for my scenario is to use an itemEditor, that has a listener put on the change event. Code looks like :

    <controls:AdvancedDataGrid id="adg">
       <controls:groupedColumns>
          <adgs:AdvancedDataGridColumn headerText="A" wordWrap="true" dataField="name" editable="false" itemEditor="Aaa"/>
        </controls:groupedColumns>
    </controls:AdvancedDataGrid>
    

    and the item editor class is here :

    <?xml version="1.0" encoding="utf-8"?>
    <mx:TextInput xmlns:fx="http://ns.adobe.com/mxml/2009" 
                  xmlns:s="library://ns.adobe.com/flex/spark" 
                  xmlns:mx="library://ns.adobe.com/flex/mx" change="textinput1_changeHandler(event)" restrict="0-9">
    
        <fx:Script>
            <![CDATA[
                protected function textinput1_changeHandler(event:Event):void
                {
                    trace("ha");
                }
            ]]>
        </fx:Script>
    
    </mx:TextInput>