1

I have a jqgrid, which has multiple columns and rows, all of which are dynamically loaded. Each column has its own validation criteria, I am using jquery.validate.js to validate the fields. All the help that I am getting is regarding the validation done on simple form fields.

Is there any way in which jqgrid cells could be validated?

For example, I have a number field, The validation check should run each time I change focus from one cell to another in the jqgrid. I already have a mechanism running that would check if the cell is switched and what value was in that cell.

This is the code that I have to perform validation:

function performCellValidation(rowId, colId, colName) {
var cellValue = $grid.jqGrid('getCell', rowId, colName);
switch (colName) {
    case 'Employee_OID':
        {
            //perform validation here
        }
}

}

faizanjehangir
  • 2,771
  • 6
  • 45
  • 83

1 Answers1

1

based on this: Common Editing Properties/Editrules

in the colmodel:

colModel: [ 
  ... 
  {name:'Employee_OID', ..., 
   editrules: {
       custom:true,
       custom_func: function(value,colname) {
                        switch (colName) {
                            case 'Employee_OID':
                            {
                                //perform validation here
                            }
                        }
                    }
   },
   editable:true },
  ...

]

this may also help: jqGrid custom edit rule function using Ajax...

Community
  • 1
  • 1
Gábor Plesz
  • 1,203
  • 1
  • 17
  • 28