我正在尝试让我的Flexicious DataGrid在单击单元格中编辑值并输入一个与原始值偏离一定百分比的新值时要求确认更改。我看不到一个简单的方法来做到这一点。最初,我尝试编写一个itemEditorValidatorFunction,它返回一个布尔值。这适用于硬编码返回值,但如果我尝试从Alert的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,但我无法确定要覆盖的方法。我想覆盖该方法,只有在单击Alert时才调用super,但是我无法看到我应该覆盖哪个方法。我试过覆盖受保护的函数onTextInput(textEvent:TextEvent):void,但这没有做任何事。
如果对此问题有所了解,我将不胜感激。
答案 0 :(得分:0)
不确定为什么有人决定对您的问题进行投票,这看起来非常有效。从这看起来,最好的方法是当用户在框中选择no时“撤消”编辑。如果启用了enableTrackChanges,您所要做的就是从dgGrid.changes集合中删除该更改并调用dgGrid.refreshCells()。如果你没有enableTrackChanges,你需要做的就是用旧值更新dataProvider行,调用dgGrid.refreshCells()然后你应该设置。
答案 1 :(得分:0)
这是有效的:
private function validateGcCap(editor:UIComponent):Boolean{
var warningBPDiffVal:Number = Number(5);
var cell:IFlexDataGridCell = managerGrid.getCurrentEditingCell();
var warningPerCentDiffVal:Number = Number(warningBPDiffVal / 1000);
var origGcCapVal:Number = Number(cell.text);
var newGcCapVal:Number = Number((editor as TextInput).text);
var diffVal:Number = Number(newGcCapVal - origGcCapVal);
if (origGcCapVal > newGcCapVal){
diffVal = origGcCapVal - newGcCapVal;
}
if (diffVal > warningPerCentDiffVal){
function alertCloseHandler(event:CloseEvent):void{
if (event.detail == Alert.CANCEL) {
IAParamsVO(cell.rowInfo.data).gcCapWrapper = origGcCapVal;
managerGrid.refreshCells();
}
}
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 true;
}