ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: ncpowerbrute66 on January 19, 2016, 10:23:56 am

Title: Check Grid Validation before calling a Saving
Post by: ncpowerbrute66 on January 19, 2016, 10:23:56 am
I am trying to check that there are no validation errors in the grid before I call ajax to save the data.  Even when the grid has a triangle in a cell and is aware there is a validation error the below .pqGrid("isValid", { rowData: rowData }) evaluates true.  What am I missing?

 var errosWithData = TargetToolDataGrid.isValid($("#grid_Top"));
        if (errosWithData == -1) {
            alert("There is nothing to save.");
        } else if (errosWithData > 0) {
            alert("There are invalid entries on row "+errosWithData+". Look for cells with a triangle in the upper right corner.");
        }


var TargetToolDataGrid = {
    isValid: function (gridToCheck) {
        debugger;
        var dataModelMgr = gridToCheck.pqGrid("option", "dataModel");
        var dataMgr = dataModelMgr.data;

        if (dataMgr.length > 0) {
            for (var i = 0, len = dataMgr.length; i < len; i++) {
                var rowData = gridToCheck.pqGrid("getRowData", { rowIndx: i });
                if (!gridToCheck.pqGrid("isValid", { rowData: rowData })) {
                    return i; //row with error
                }
            }
            return 0;  // zero errors
        }
        return -1; //no data
    }
}
 
Title: Re: Check Grid Validation before calling a Saving
Post by: paramvir on January 19, 2016, 11:17:08 am
Code: [Select]
if (!gridToCheck.pqGrid("isValid", { rowData: rowData }))

needs to be corrected to

Code: [Select]
if ( !gridToCheck.pqGrid("isValid", { rowData: rowData }).valid )