Jquery JQGrid – How to get the contents of a cell in edit mode

jqgridjquery

I have a grid with 2 editable cells, and can get the value of the current cell with:

var editedValue = this.value;

But how do I get the value of the other cell? Currently I'm using the very ugly:

var otherValue = this.parentNode.nextSibling.firstChild.value;

But this is not safe (and has cross browser issues).

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods says that the getCell method can not be used when editing a row – so how can you get the value of a cell when it is in edit mode?

Best Answer

I'll answer it myself with this simple jquery function:

function GetEditCellValue(rowSelector, cellName) {
    var rowId = rowSelector.split('_')[0];
    return  $("#" + rowId + "_" + cellName).val();
}

Call it from the column's dataEvent like so:

dataEvents:
    [
    { type: 'blur',  fn: function (e) {
        var someEditedValue = GetEditCellValue(this.id, "SomeColumnName");