当我单击单元格以编辑值并输入与原始值相差一定百分比的新值时,我试图让我的 Flexicious DataGrid 要求确认更改。我看不到一个简单的方法来做到这一点。最初,我尝试编写一个 itemEditorValidatorFunction,它返回一个布尔值。这对于硬编码的返回值非常有效,但是如果我尝试从警报的 CloseEvent 中获取返回值,则该值将被忽略:
protected function validateGcCap(editor:UIComponent):Boolean{
var warningBPDiffVal:Number = Number(5);
var warningPerCentDiffVal:Number = Number(warningBPDiffVal / 1000);
var allowChange:Boolean = true;
var origGcCapVal:Number = Number(managerGrid.getCurrentEditingCell().text);
var newGcCapVal:Number = Number((editor as TextInput).text);
var diffVal:Number = Number(newGcCapVal - origGcCapVal);
if (origGcCapVal > newGcCapVal) {
diffVal = origGcCapVal - newGcCapVal;
}
if (diffVal > warningPerCentDiffVal) {
//Alert.show("you changed the gccap from " + origGcCapVal + " to " + newGcCapVal + " by " + diffVal);
function alertCloseHandler(event:CloseEvent):void{
if (event.detail == Alert.CANCEL) {
allowChange = false;
}
};
var alert:Alert = Alert.show("Are you sure that you want to update gcCap% by more than " + warningBPDiffVal + "bps?",
"Please Confirm", (Alert.OK | Alert.CANCEL),
this, alertCloseHandler);
}
return allowChange;
}
我还尝试为网格编写一个 itemEditor:FlexDataGridColumn,我在其中扩展了 com.flexicious.controls.TextInput,但我无法确定要覆盖的方法。我想覆盖该方法,并且仅在单击“确定”警报时才调用 super,但是我看不到应该覆盖哪个方法。我尝试覆盖受保护的函数 onTextInput(textEvent:TextEvent):void,但这什么也没做。
我将不胜感激对这个问题的任何见解。