Aberel
Aberel

Reputation: 162

Jqgrid custom_func validation and get all row edit values

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" ...
}

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.

I am using jqGrid 4.6.0

Upvotes: 0

Views: 1249

Answers (1)

Oleg
Oleg

Reputation: 221997

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.

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 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

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

Upvotes: 1

Related Questions