You can use first :nth-child selector to get <td>
elements having checkboxs in the grid. Then you can use >input:checked
selector to get all checked checkboxs. After you have jQuery object which contains the requested checkboxes you can use .closest("tr.jqgrow")
to get rows having the checkboxes. The ids of the rows is what you need. You can use $.map
to get all ids in the array. The full code will be
$("#getIds").button().click(function () {
var $checked = $grid.find(">tbody>tr.jqgrow>td:nth-child(" +
(iCol + 1) + ")>input:checked"),
ids = $.map($checked.closest("tr.jqgrow"),
function (item) { return item.id; });
alert("The list of rowids of the rows with checked chechboxs:\n" + ids.join());
});
where the index of the column with checkboxs iCol
you can get using getColumnIndexByName
function
var getColumnIndexByName = function (grid, columnName) {
var cm = grid.jqGrid("getGridParam", 'colModel'), i, l;
for (i = 0, l = cm.length; i < l; i += 1) {
if (cm[i].name === columnName) {
return i; // return the index
}
}
return -1;
};
which I frequently used in my old answers.
The demo demonstrate the above code live.