reverting row which escape is clicked and fixed the issue with reverting rows (#1333)

* reverting row which escape is clicked and fixed the issue with reverting row
This commit is contained in:
Leila Lali
2018-05-02 15:57:15 -07:00
committed by GitHub
parent 8bf60f133f
commit 6d243e0ac8

View File

@@ -52,7 +52,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
private currentEditCellValue: string; private currentEditCellValue: string;
private newRowVisible: boolean; private newRowVisible: boolean;
private removingNewRow: boolean; private removingNewRow: boolean;
private rowIdMappings: {[gridRowId: number]: number} = {}; private rowIdMappings: { [gridRowId: number]: number } = {};
// Edit Data functions // Edit Data functions
public onActiveCellChanged: (event: { row: number, column: number }) => void; public onActiveCellChanged: (event: { row: number, column: number }) => void;
@@ -203,10 +203,12 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
return (index: number): void => { return (index: number): void => {
// Force focus to the first cell (completing any active edit operation) // Force focus to the first cell (completing any active edit operation)
self.focusCell(index, 0, false); self.focusCell(index, 0, false);
this.currentEditCellValue = null;
// Perform a revert row operation // Perform a revert row operation
self.dataService.revertRow(index) self.dataService.revertRow(index)
.then(() => self.refreshResultsets()); .then(() => {
self.refreshResultsets();
});
}; };
} }
@@ -294,7 +296,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
}); });
// Cap off any failed promises, since they'll be handled // Cap off any failed promises, since they'll be handled
cellSelectTasks.catch(() => {}); cellSelectTasks.catch(() => { });
} }
handleComplete(self: EditDataComponent, event: any): void { handleComplete(self: EditDataComponent, event: any): void {
@@ -415,6 +417,10 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
this.newRowVisible = false; this.newRowVisible = false;
}); });
handled = true; handled = true;
} else if (e.keyCode === jQuery.ui.keyCode.ESCAPE) {
this.currentEditCellValue = null;
this.onRevertRow()(this.currentCell.row);
handled = true;
} }
return handled; return handled;
} }
@@ -515,7 +521,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
}, this.scrollTimeOutTime); }, this.scrollTimeOutTime);
} }
private focusCell(row: number, column: number, forceEdit: boolean=true): void { private focusCell(row: number, column: number, forceEdit: boolean = true): void {
let slick: any = this.slickgrids.toArray()[0]; let slick: any = this.slickgrids.toArray()[0];
let grid = slick._grid; let grid = slick._grid;
grid.gotoCell(row, column, forceEdit); grid.gotoCell(row, column, forceEdit);