如何使用jquery.validate.js验证jqgrid中的单元格? [英] how to use jquery.validate.js to validate cells in jqgrid?
问题描述
我有一个 jqgrid ,其中有多个列和行,所有这些列和行都是动态加载的.每列都有自己的验证条件,我正在使用 jquery.validate.js 来验证字段.我得到的所有帮助都是关于在简单表单字段上完成的验证.
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.
有什么方法可以验证jqgrid细胞?
Is there any way in which jqgrid cells could be validated?
例如,我有一个数字字段,每次将焦点从jqgrid中的一个单元格更改为另一个单元格时,都应运行验证检查.我已经运行了一种机制,可以检查单元格是否已切换以及该单元格中的值是什么.
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
}
}
}
推荐答案
基于此:常用编辑属性/编辑规则
在colmodel中:
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 },
...
]
这可能也有帮助:使用Ajax的jqGrid自定义编辑规则功能...
这篇关于如何使用jquery.validate.js验证jqgrid中的单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!