Jqgrid custom_func验证并获取所有行编辑值 [英] Jqgrid custom_func validation and get all row edit values

查看:341
本文介绍了Jqgrid custom_func验证并获取所有行编辑值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在另一个问题中进行了评论( jqgrid editoptions custom_func具有required = false ),现在我需要使用custom_func验证输入.该验证要求将输入值与用户输入的其他列值进行比较.换句话说,需要先获取所有当前行的值,然后才能提交来确定验证结果. 我设法通过这种方式获得了一些特定的专栏...

As it commented in another question (jqgrid editoptions custom_func with required=false) , now I need to validate input with custom_func. This validation requires to compare the input value with another columns values entered by the user. In other words, need to get all the current row values before submit to decide the validation result. I managed to get some specific column this way...

function myCustomFunc(value, colName) {
    //consider I have a global var "selRowId" which is updated onSelectRow event.
    var someColValue = $('select#'+selRowId+'_someColName').val();
    // ... here the validation using the "someColValue" ...
}

我认为这不是最好的方法.我希望有一种方法可以返回类似于"getRowData"的对象,但包含用户的所有输入值.

I think this is NOT the best method. I would prefer some method which returns an object similar to "getRowData" but containing all the input values from the user.

我正在使用jqGrid 4.6.0

I am using jqGrid 4.6.0

推荐答案

似乎您在使用内联编辑. 4.6版中的jqGrid无法访问当前值,但是免费jqGrid的当前来源(来自GitHub的早期版本4.13.7)包含新的回调saveRowValidation和事件jqGridInlineSaveRowValidation,这可以简化您的操作需要实施.

It seems that you use inline editing. jqGrid in the version 4.6 has no other possibilities to access to the current values, but the current sources of free jqGrid (preliminary version 4.13.7 from GitHub) contains new callback saveRowValidation and the event jqGridInlineSaveRowValidation, which could simplify what you need to implement.

回调saveRowValidation包含一个参数,就像在免费jqGrid中实现的大多数其他回调一样.参数,我们命名为options,包含以下属性

The callback saveRowValidation contains one parameter, like the most other callbacks implemented in free jqGrid. The parameter, let us we name it options, contains the following properties

  • mode的值为"edit""add"
  • rowid-编辑行的id属性的值
  • newData-具有已修改行数据的对象
  • savedRow-具有编辑前行数据的对象
  • options-内联编辑选项
  • iRow-从网格顶部开始的行的索引
  • tr-DOM元素,代表编辑行
  • mode with the value "edit" or "add"
  • rowid - the value of id attribute of the editing row
  • newData - the object with modified data of the row
  • savedRow - the object with the data of the row before editing
  • options - the options of inline editing
  • iRow - the index of the row from the top of the grid
  • tr - DOM element, which represent the editing row

我认为options.newData是您所需要的.有关更多详细信息,请参见对提交的评论.

I think that options.newData is what you need. See the comment to the commit for more details.

这篇关于Jqgrid custom_func验证并获取所有行编辑值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆