ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: kshipra on June 19, 2017, 02:58:44 pm

Title: get summary of validation errors from grid.isValid
Post by: kshipra on June 19, 2017, 02:58:44 pm
Before sending changes to server,  I am calling grid.isValid function to check if no validation errors exist.

How can i get summary of all errors if grid is not valid, so I can display the list to users?

if (isDirty) {
                //validate the new added rows.               
                var addList = grid.getChanges().addList;
                for (var i = 0; i < addList.length; i++) {
                    var rowData = addList;
                    var isValid = grid.isValid({ "rowData": rowData }).valid;
                    if (!isValid) {
                        alert("Newly added data not valid");
                    }
                }
                var changes = grid.getChanges({ format: "byVal" });

                //post changes to server
                $.ajax({
                    dataType: "json",
                    type: "POST",
.....
Title: Re: get summary of validation errors from grid.isValid
Post by: paramvir on June 20, 2017, 12:24:31 pm
That is automatically done by the grid when isValid/ isValidChange methods are used as shown in example of batch editing.

However if you want to collect the list of invalid cells & errors yourself.

Code: [Select]
grid.isValidChange({allowInvalid:true}).cells.forEach(function(cell){
var obj = grid.isValid(cell); //obj.msg is the error message for every invalid cell.
});

Please read the description of the used methods in the API

https://paramquery.com/pro/api#method-isValidChange
https://paramquery.com/pro/api#method-isValid