Checkboxes will only work on current pagination page in jQuery datatables

后端 未结 2 1035
半阙折子戏
半阙折子戏 2021-01-16 00:34

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.

相关标签:
2条回答
  • 2021-01-16 01:10

    You can check them at the end.

    var table = $("#yourtablename").DataTable({
        //your datatable options(optional)
    });
    

    Now jQuery have access to all the rows by following code

      table.$('td > input:checkbox').each(function () {
                // If checkbox is checked
                if (this.checked) {
                 //Your code for example
                    alert($(this).attr('name'));
                }
        }); 
    
    0 讨论(0)
  • 2021-01-16 01:12

    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();
        }
    });
    
    0 讨论(0)
提交回复
热议问题