【发布时间】:2015-05-30 03:04:31
【问题描述】:
var data = [[48803,"true"], [48769,"true"]];
$("#grid").jqGrid({
datatype: "local",
height: 250,
colNames: ['Inv No','MyPrint'],
colModel: [{
name: 'id',
index: 'id',
width: 60,
sorttype: "int"},
{
name: 'MyPrint',
index: 'MyPrint',
width: 80,
editoptions: { value: "True:False" },
editrules: { required: true },
edittype: 'checkbox',
formatter: myPrintCheckboxFormatter,
formatoptions: { disabled: false },
editable: true }
],
caption: "test example"
});
var names = ["id","true"];
var mydata = [];
for (var i = 0; i < data.length; i++) {
mydata[i] = {};
for (var j = 0; j < data[i].length; j++) {
mydata[i][names[j]] = data[i][j];
}
}
for (var i = 0; i <= mydata.length; i++) {
$("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}
function myPrintCheckboxFormatter(cellvalue, options, rowObject) {
//how to pass currently selcted id of row
return "<input type='checkbox' name='MyPrint' onchange='getCurrentBinRow()'>";
}
function getCurrentBinRow() {
/*here I want to get the current selected MyPrint row*/
var id= $('#grid').jqGrid('getGridParam', 'selrow'); // id becomes null
}
如何检索选定的行 id?,我已经尝试过,但得到了 null。 我不明白如何从 onchange 事件 javascript 函数 getCurrentBinRow 传递它。我想将检查和未检查状态传递给服务器,如果你检查了行的 css 需要背景红色,并且在未检查 css 后需要在行
【问题讨论】: