Posted 24 January 2019, 3:13 pm EST
Hi,
I have Flex grid in Angular 6 application. When user enters invalid value I display red border around invalid cell and when cell becomes valid I remove red border. When cell is invalid and user clicks on the other cell I cancel edit and put focus back on the invalid cell forcing user to fix the problem before editing the other cell. This worked perfect in Angular 1. In Angular 6 cancel edit does not fully works. Please see my code below. For some reason I need to call startEditing in setTimeout. If I comment out setTimeout I am able to edit the other cell. The invalid cell does not get focus after I click the other cell. If I uncomment setTimeout invalid cell gets focus after I click the other cell but if I click the other cell and quickly type I am able to enter value in the other cell when invalid cell is present. The focus stays on the other cell instead of being put on the invalid cell.
Please help me implement edit cancel correctly so that user is forced to fix invalid cell before be able to change the other cell.
selectionChanging(s, e) {
if (this.hasValidationErrors) {
//e.cancel = true;
setTimeout(() => {
e.cancel = true;
s.startEditing(true, this.editedRow, this.editedColumn);
});
}
}
thank you
