如何在jquery数据表中查找单选按钮的列索引
嗨,我想知道单选按钮在数据表中选择的列索引 以下是我的数据表代码:如何在jquery数据表中查找单选按钮的列索引,jquery,datatables,jquery-datatables,Jquery,Datatables,Jquery Datatables,嗨,我想知道单选按钮在数据表中选择的列索引 以下是我的数据表代码: $(document).ready(function() { table = $('#ReportTable').dataTable({ "bProcessing": true, "bPaginate": false, "bJQueryUI": true, "ajax": { url: 'ajax_call.php',
$(document).ready(function() {
table = $('#ReportTable').dataTable({
"bProcessing": true,
"bPaginate": false,
"bJQueryUI": true,
"ajax": {
url: 'ajax_call.php',
type: "POST",
data: {
action: 'loadEmailData'
}
},
"columnDefs": [{
"aTargets": [0],
"mRender": function(data, type, full) {
id = full[3];
var returnval = "<td><input type='radio' name='chkNew" + id + "' class='call-checkbox' value=" + id + " id=\"chkNew'" + id + "'\" /></td>";
return returnval;
}
}, {
"aTargets": [1],
"mRender": function(data, type, full) {
id = full[3];
var returnval = "<td><input type='radio' name='chkNew" + id + "' class='call-checkbox' value=" + id + " id=\"chkSubmit'" + id + "'\" /></td>";
return returnval;
}
}, {
"aTargets": [2],
"mRender": function(data, type, full) {
id = full[3];
var returnval = "<td><input type='radio' name='chkNew" + id + "' class='call-checkbox' value=" + id + " id=\"chkDeploy'" + id + "'\"/></td>";
return returnval;
}
}
]
});
});
您可以使用以下命令触发单选按钮上的更改事件。委托:
.代表
将处理程序附加到与事件匹配的所有元素的一个或多个事件
选择器,现在或将来,基于一组特定的根
元素
这里的变化是什么?我更正了答案。选择单选按钮时更改事件触发器。上面的解决方案显示单击单选按钮的值,但我需要列索引号,无论是第0列、第1列还是第2列。。
rowcollection.each(function(index,elem){
var checkbox_value = $(elem).val(),
globalindex = $(this).closest('tr')find('input[type="radio"]').index(this);
arr[globalindex]=checkbox_value;
alert(globalindex);
});
$( "#ReportTable" ).delegate("input[type='radio']", "change", function() {
var $this = $(this);
var id = $this.val();
// do sth
});