Author Topic: Check Grid Validation before calling a Saving  (Read 2095 times)

ncpowerbrute66

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Check Grid Validation before calling a Saving
« 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
    }
}
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Check Grid Validation before calling a Saving
« Reply #1 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 )