2011-03-29 75 views
0

dataChange事件這是我的代碼:監聽在AdvancedDataGrid

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

,並在我的ActionScript代碼:

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

當我編輯advancedDataGrid細胞(使編輯過程中的列)它從不發送事件。換句話說,我的功能從未被調用。我怎樣才能解決這個問題?

+0

您是否嘗試過添加事件監聽到的dataProvider COLLECTION_CHANGE事件? – 2011-03-30 16:19:12

回答

1

我認爲我的方案更好的選擇是使用一個itemEditor,它有一個監聽器放在change事件上。代碼如下所示:

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

和項目編輯類是在這裏:

<?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>