0
嗨我想知道單選按鈕在數據表中選擇的列索引。如何找到jQuery數據表中單選按鈕的列索引
這裏是我的數據表代碼:
$(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;
}
}
]
});
});
這裏是函數來獲得所選擇的列索引和選擇列的ID:這是警報柱像0.1的指數。如果我點擊第1和第3欄也很警覺0,1,應該警惕0,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);
});
什麼是「更改」。 – user3829086 2014-12-05 16:01:57
我改正了答案。每當單選按鈕被選中時,'.change'事件觸發器。 – 2014-12-05 16:07:27
您好上面的解決方案是顯示單擊單選按鈕的值,但是我想列索引號是否爲0,1,2列。 – user3829086 2014-12-08 10:41:41