0

My datatable contains several pages of data, and I have a column of checkboxes, with a checkbox being in the header as well.

I basically want to check all of the checkboxes on the same page of the datatable when the header checkbox is selected. While it's working, it's also jumping me to different pages of the datatable.

For example, if I'm on page 4 of the table and I click the checkbox in the header row, it selects all of the checkboxes just fine, but then it jumps to page 1 on the table (with the checkbox still selected)

Can someone tell me what I'm doing wrong? Here's the .js that's being loaded with the page containing the table:

$('#issues').dataTable();
$("#checkAllIssues").click(function(){
    $('input:checkbox').not(this).prop('checked', this.checked);
});

* EDIT *

I think I just found the issue. Any time I sort a column, it changes back to page 1 of the table. I think the checkbox cell should be made non-sortable for this to stop doing this.

SOLUTION

I simply had sortable rows still enabled, and that affected me. I had to disable sorting on the checkbox column so that checking the checkbox in the header row did not cause the table to be sorted and redirected back to page 1.

3
  • Refer this SO answer: stackoverflow.com/questions/22068623/… Commented Jan 15, 2016 at 1:53
  • Got it working! :) Had to disable column sorting because sorting the table always jumps it back to page 1. Commented Jan 15, 2016 at 2:42
  • you can answer your own question that will be useful for others too Commented Jan 15, 2016 at 4:55

1 Answer 1

0

Got this working by simply making sure the table column that contains the checkboxes aren't sortable. Because the datatable naturally jumps to page 1 after sorting a column, clicking the checkbox was sorting the table, causing it to jump back to page 1.

Sign up to request clarification or add additional context in comments.

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.