Full validation
This function not only checks the validity of the user's input data, but also checks the validity of existing loaded data. You can use gridView.validateCells(itemIndices) to check specific data rows or all rows. You can use gridView.getInvalidCells() to get the list of current validation failures.
validateCells() must be executed before executing getInvalidCells().
Validity Settings
Set validity in the payment column.
gridView.onValidateColumn = function(grid, column, inserting, value, itemIndex, dataRow) {
var error = {};
if (column.fieldName === "SaveCost") {
if (value < 50000) {
error.level = "error";
error.message = "Payment must be over 50,000.";
}else if(value > 100000){
error.level = "warning";
error.message = "Payment must be less than 100,000.";
}
};
return error;
}
Batch validation
You can batch validate loaded data using gridView.validateCells(itemIndices). After validation, returns a list of failures.
If you do not enter anything as a transfer argument, validation is performed on all rows, and when validating only specific rows, you can pass the row numbers as an array.
var log = gridView.validateCells(null, false);
alert(JSON.stringify(log));
List of validation failures
After gridView.validateCells(itemIndices), when correcting error values and checking again for invalid values, [gridView.getInvalidCells()](/refs/Class/GridBase# getinvalidcells).
Edit the rows that failed validation and click the button to see if the rows you edited are excluded.
var log = gridView.getInvalidCells();
alert(JSON.stringify(log));
Reset verification failure list
Delete cell information that failed value verification. It is used to first execute gridView.validateCells(itemIndices) and then clear the list of data that failed the imported verification.
gridView.clearInvalidCells();