Check Box "Check All" does not work for all pages using datatables

Asked

Viewed 185 times

1

Setting: I’m using Datatables to show a list of cities, and each of them has a checkbox. I also have a "Check All" in which, obviously, when marked, all cities should be marked as well.
Problem: When I mark the "Check All", only the first page cities are selected.
To mark the checkboxes use the $(selector).each().

`$('.chkCidade').each(function () {
        $(this).attr('checked', true)
 });`


Can you help me?

  • You can just $('.chkCidade').attr('checked', true). Doubt: the checks for the other pages are loaded on the front? Or the pagination is via back-end or created in the page change?

  • I send the list of c# to the view, and there in the view I create the table going through this list, the same problem occurs by using Jquery Datatables, I think. In paging, it shows 10 cities at a time, so when I check all, it selects only these 10. I confess that I do not understand how Datatables works, but I believe that it creates these check on page change.

  • My guess is that the identifiers of the other pages are the same as the first. You could make the checkAll via c#..

  • I found the solution here

  • Cool! You can answer your own question, maybe it will help someone who goes through the same thing some day.

1 answer

0

I found the answer here. This is the manipulation of table Rows when using Jquery Datatables.

  • Instead of putting the links, could explain what was the problem and the code snippets that used to solve Ricardo.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.