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?– BrTkCa
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.
– Ricardo Alves
My guess is that the identifiers of the other pages are the same as the first. You could make the checkAll via c#..
– BrTkCa
I found the solution here
– Ricardo Alves
Cool! You can answer your own question, maybe it will help someone who goes through the same thing some day.
– BrTkCa