vasyapunk
30.07.2010, 19:57
Почему если поставить для DataGrid функцию на событие ItemEditEnd, то эта функция срабатывает несколько раз?
Вот мой mxml:
<mx:DataGrid rowCount="8"
sortableColumns="false"
id="yearGrig" dataProvider="{buildGridData}"
height="100%" editable="true" itemEditEnd="onItemEditEnd(event)">
<mx:columns>
<mx:DataGridColumn headerText="Description\Year" dataField="label" width="160"
backgroundColor="#CCCCC9"
textAlign="right" fontWeight="bold" editable="false"
/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearMinusTwu" dataField="yearMinusTwo" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearMinusOne" dataField="yearMinusOne" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="todayYear" dataField="todayYear" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearPlusOne" dataField="yearPlusOne" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearPlusTwu" dataField="yearPlusTwo" labelFunction="format"/>
</mx:columns>
</mx:DataGrid>
И скрипт к нему:
private function onItemEditEnd(event:DataGridEvent):void{
var currentColumn:String;
if(event.columnIndex==1){
currentColumn="yearMinusTwu";
}else if(event.columnIndex==2){
currentColumn="yearMinusOne";
}else if(event.columnIndex==3){
currentColumn="todayYear";
}else if(event.columnIndex==4){
currentColumn="yearPlusOne";
}else if(event.columnIndex==5){
currentColumn="yearPlusTwu";
}
Alert.show(buildGridData[event.rowIndex]['label'].toString()+' = '+buildGridData[event.rowIndex][currentColumn].toString());
event.preventDefault();
yearGrig.destroyItemEditor();
}
Вот тот алерт выполняется сейчас 3 раза.Почему?
Если кто с таким сталкивался, помогите плиз)
Вот мой mxml:
<mx:DataGrid rowCount="8"
sortableColumns="false"
id="yearGrig" dataProvider="{buildGridData}"
height="100%" editable="true" itemEditEnd="onItemEditEnd(event)">
<mx:columns>
<mx:DataGridColumn headerText="Description\Year" dataField="label" width="160"
backgroundColor="#CCCCC9"
textAlign="right" fontWeight="bold" editable="false"
/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearMinusTwu" dataField="yearMinusTwo" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearMinusOne" dataField="yearMinusOne" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="todayYear" dataField="todayYear" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearPlusOne" dataField="yearPlusOne" labelFunction="format"/>
<mx:DataGridColumn headerText="" width="90" editable="true"
id="yearPlusTwu" dataField="yearPlusTwo" labelFunction="format"/>
</mx:columns>
</mx:DataGrid>
И скрипт к нему:
private function onItemEditEnd(event:DataGridEvent):void{
var currentColumn:String;
if(event.columnIndex==1){
currentColumn="yearMinusTwu";
}else if(event.columnIndex==2){
currentColumn="yearMinusOne";
}else if(event.columnIndex==3){
currentColumn="todayYear";
}else if(event.columnIndex==4){
currentColumn="yearPlusOne";
}else if(event.columnIndex==5){
currentColumn="yearPlusTwu";
}
Alert.show(buildGridData[event.rowIndex]['label'].toString()+' = '+buildGridData[event.rowIndex][currentColumn].toString());
event.preventDefault();
yearGrig.destroyItemEditor();
}
Вот тот алерт выполняется сейчас 3 раза.Почему?
Если кто с таким сталкивался, помогите плиз)