4

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.

1
  • this is the default functionality.. how can you submit the data which are not listed or visible? check your gmail inbox, it works like the same.. Commented Jun 9, 2015 at 5:55

2 Answers 2

6

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();
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

No, I want to get specific selsected data from previous page too.
In above code,you have assigned value to id but how can i appendTo(this) so can get all data i post?
2

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'));
            }
    }); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.