I would like to know the best way to do validation of multiple items.
# specification
1. "Judge"== false -> update NG
| flag0 | flag1 | judge |
|---|---|---|
| False | False | True |
| False | True | True |
| True | False | False |
| True | True | True |
# pattern 1
1. colModel validation
function validVisible(ui) {
let col = ui.column,
row = ui.rowData,
flg0 = (col.dataIndx === "flag0" ? ui.value : row.flag0),
flg1 = (col.dataIndx === "flag1" ? ui.value : row.flag1);
if (flg0 === true && flg1 === false) {
ui.msg = "error message!";
return false;
}
return true;
}
let colMod = [
{ title: "flag0", dataIndx: "flag0", dataType: "bool", type: "checkbox",
validations: [{ type: validVisible }]
}),
{ title: "flag1", dataIndx: "flag1", dataType: "bool", type: "checkbox",
validations: [{ type: validVisible }]
}),
* The difficulty, this method leaves a message in one of the items.
# pattern 2
1. demo "Row Editing" - How to do with "update"
function update(rIndx, grid) {
if (grid.saveEditCell() === false) { return false; }
if (grid.isValid({ rowIndx: rIndx, focusInvalid: true }).valid === false) { return false; }
// this.
let row = grid.getRowData({ rowIndx: rIndx });
if (row.flag0 === true && row.flag1 === false) {
grid.focus({ rowIndxPage: rIndx, colIndx: 1 });
return false;
}
:
* The difficulty, this method can not issue a message.
Please tell me if there is any other good way.