复选框仅适用于jQuery数据表中的当前分页页 [英] Checkboxes will only work on current pagination page in jQuery datatables

查看:281
本文介绍了复选框仅适用于jQuery数据表中的当前分页页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery数据表列出我的内容,其中包含复选框选择和选定的内容发布数据,但以提交的形式只发送当前页面数据。



我的数据表代码是:

  $('#select')。dataTable({
order:[[2 ,desc]],
lengthMenu:[[50,-1],[50,全部]],
columnDefs:[
{orderable:目标:[0,1,3,5]},
{width:20px,targets:[0,1]},
{width:80px targets:[5]}
],

});

当我点击提交时,它只提交当前页面值的复选框数组。 p>

我已经引用了这个链接使用所选复选框进行分页。复选框只适用于当前分页页。 jQuery数据表,但解决方案提供的链接和链接不起作用。

解决方案

您可以获得所有选定的检查使用以下代码的框值可能对您有帮助

  var myArray = []; 
var id =;
var oTable = $(#example)。dataTable();
$(。class1:checked,oTable.fnGetNodes())。each(function(){
if(id!=){
id = id + + $(this).val();
} else {
id = $(this).val();
}
});


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.

My Data table code is:

$('#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.

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数据表中的当前分页页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆