Posted 20 November 2018, 7:20 am EST
I am searching on ways to do cell validation, and found the following: https://demos.wijmo.com/5/Angular/GridValidation/GridValidation/That looks really great for my needs.
-I want the ability to mark a cell as invalid (while the user is able to continue making changes by using validateEdits = false;)
- I want the ability to add a tooltip to the corner of the cell displaying an error message to the user to assist in their solving of the error.
The example provided by the above link does not work with how I use flexsheet, as I dynamically create my workbook from server data:
// Dynamically creating bound sheets for the flexsheet control one by one
this.ServerWorkbook.addBoundSheet(dataFromServer[i].SheetName, this.workbookData.WorkSheets[i]);
I loop through all the sheets from the server and create a complete workbook on the client. I don't see a way to add or define getError(), or know how to use it exactly.
I do have logic programmed for errors already, in addition to text validation on the cell. This logic might be cell values being equal to another cell, for example. At the core, I evaluate the input, and either add the cell to an array or cells in error {worksheetIndex, Col, Row} or it is not part of the error array.
this.ServerWorkbook.cellEditEnded.addHandler((s, e: any) => {
// in order to save time and keep grid responsive, i don't want to check errors unless the data entered is new
const prevData = e.data;
const curData = s.getCellData(e.row, e.col);
if(prevData === curData){
// no change return
return;
}
// this is my custom logic to determine if there are errors. It keeps track of errors with an array of cells for displaying in custom UI
// of note: this is more than just text validation, this also has logical checks against other data points.
this.checkForErrors(e.row, e.col);
});
While I display a list of cells in error in my own custom UI, I would love the ability to display the cells in an error state in the grid (wj-state-invalid), display a tooltip on hover in the corner, and have the ability from my UI to click a button "go to error" which would change the active worksheet of the workbook to the proper sheet, scroll down to the row/col containing the error, and have the cursor active and editing the error cell using my error handlers array containing the cell's worksheet index/col/row.
When the data is changed for a cell and cellEditEnded runs again and the error state is cleared, it's removed from the error array, and then the cell should return to normal state (wj-state-invalid class and tooltip removed) on the grid as well.
Perhaps jumping to the cell on a button is better suited for a different question, but it is two features I would like for my error handling process.