ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: ohbayashi on May 23, 2017, 01:03:42 pm
-
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.
-
First one leaves a message and 2nd one doesn't leave a message.
your requirement is not clear enough to me. Can you please rephrase and clarify it.
-
Thank you. I solved it self-resolved.
function update(rIndx, grid) {
if (grid.saveEditCell() === false) { return false; }
if (grid.isValid({ rowIndx: rIndx, focusInvalid: true }).valid === false) { return false; }
if ("validationMultiple" in grid.options) {
if (grid.options.validationMultiple(rIndx, grid) === false) { return false; }
}
:
let gridObj = {
validationMultiple: function(rIndx, grid) {
let row = grid.getRowData({ rowIndx: rIndx });
if (row.visible_flag === true && row.pm_commit_flag === false) {
$("#err_result").text("<< Error on update >>");
$("#err_detail").text("err_message. row:" + (rIndx + 1));
return false;
} else {
$("#err_result").text("");
$("#err_detail").text("");
}
return true;
},
:
let $grid = pq.grid("#gridMain", gridObj);