如何检索选定的行ID ?,我试过但得到空值. 我不明白如何从onchange事件javascript函数getCurrentBinRow.it传递它,我想将已检查和未检查状态传递给服务器,如果您检查了行的CSS,则需要背景为红色,而未经检查的CSS,则需要在行中
How to retrive selected row id ?,i have tried but getting null. I does not understand how to pass it from onchange event javascript function getCurrentBinRow.i want to pass checked and unchecked status to server and if you checked the css of row need to background red and after unchecked css need to at row
推荐答案您可以执行以下操作:
function myPrintCheckboxFormatter(cellvalue, options, rowObject) { return "<input type='checkbox' name='MyPrint' onchange='getCurrentBinRow(this)'>"; } //---------------------------------------------------pass this in here-----^^^^ function getCurrentBinRow(elem) { var id = $(elem).closest('tr')[0].id; $(elem).closest('tr').toggleClass('redRow'); // adds red bgcolor when checked. alert(id); }将此CSS添加到样式表中:
add this css in your stylesheet:
.redRow{ background:red !important; }更新:
您甚至也可以这样做:
Update:
You can even do this too:
自定义格式化程序中有options参数,其中有rowId可用.因此您可以在onchange函数中传递options.rowId.
You have options param in the custom formatter where you have rowId available in it. so you can pass options.rowId in the onchange function.
function myPrintCheckboxFormatter(cellvalue, options, rowObject) { return "<input type='checkbox' name='MyPrint' onchange='getCurrentBinRow(" + options.rowId + ")'>"; } //-------------------------------------------------------pass this in here-----^^^^^^^^^^^^^^ function getCurrentBinRow(rowid) { alert(rowid); }更多推荐
如何在带有可编辑复选框的jq网格中获取选定的复选框行ID
发布评论