user142617
user142617

Reputation: 386

JQGrid Select Row

I have a custom checkbox column on my JQGrid, each time the user clicks on the checkbox I would like to display all the row information in a message box.

My jsfiddle:

I have tried the following, but does nothing:

function getCurrentBinRow() {
       var grid = $('#grid'),
           selRowId = grid.jqGrid('getGridParam', 'selrow'),
           celValue = grid.jqGrid('getCell', selRowId, 'Inv No');
}

Thanks

Upvotes: 1

Views: 453

Answers (1)

Oleg
Oleg

Reputation: 221997

One can use simple formatter: "checkbox" with formatoptions: { disabled: false } and use beforeSelectRow to detect changing of the checkbox:

beforeSelectRow: function (rowid, e) {
    var $self = $(this),
        iCol = $.jgrid.getCellIndex($(e.target).closest("td")[0]),
        cm = $self.jqGrid("getGridParam", "colModel"),
        localData = $self.jqGrid("getLocalRow", rowid);
    if (cm[iCol].name === "MyPrint" && e.target.tagName.toUpperCase() === "INPUT") {
        // set local grid data
        localData.MyPrint = $(e.target).is(":checked");
        alert(JSON.stringify(localData));
    }

    return true; // allow selection
}

See http://jsfiddle.net/OlegKi/rk7b1dbx/9/. See the answer on very close question.

Upvotes: 1

Related Questions