問題描述
我正在使用 jquery 數據表列出我的內容,其中有復選框選擇和選定的內容發布數據,但在提交的表單中僅發送當前頁面數據.
I am using jquery data table for listing my content which have checkbox selection and selected content post the data but in submitted form only current page data sent.
我的數據表代碼是:
$('#select').dataTable( {
"order": [[ 2, "desc" ]],
"lengthMenu": [[50, -1], [50, "All"]],
"columnDefs": [
{ orderable: false, targets: [0, 1, 3, 5] },
{ "width": "20px", "targets": [0, 1] },
{ "width": "80px", "targets": [5] }
],
});
當我點擊提交時,它只提交當前頁面值的復選框數組.
When I click on submit, it only submit the array of checkboxes for the current page values.
我已經提到了這個鏈接 帶有選中復選框的分頁.復選框僅適用于當前分頁頁面.jQuery 數據表,但那里提供的帶有鏈接和鏈接的解決方案不起作用.
I have referred this link already Pagination with selected check boxes. Checkboxes will only work on current pagination page. jQuery datatables but solution provided overthere with link and link is not working.
推薦答案
您可以使用以下代碼獲取所有選中的復選框值,這可能對您有所幫助
you can get all the selected check box values using following code this might be helpful for you
var myArray = [];
var id = "";
var oTable = $("#example").dataTable();
$(".class1:checked", oTable.fnGetNodes()).each(function() {
if (id != "") {
id = id + "," + $(this).val();
} else {
id = $(this).val();
}
});
這篇關于復選框僅適用于 jQuery 數據表中的當前分頁頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!