How do i uncheck all header checkbox using jquery
How do i uncheck all header checkbox using jquery

Hello,
I am using a gyrocode checkbox plugin with my DataTable.
Initially i check some records, edit them and uncheck the checkbox using this below code.
$('input[type="checkbox"]', table.cells().nodes()).prop('checked',false);
Now i again select some other records, this time when i fetch IDs of selected checkbox, previous records are included in the array returned.
So i decided to uncheck the main check box in a header column which will select/ Deselect all the records.
How do i do that ?
This question has an accepted answers - jump to answer
Answers
Hi @DeepaMGMG ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Formatted
Formatted
Hi Colin, Thank you so much for help.
I am unable to use live.datatables.net. I will try to explain my issue below here.
==> I Have a DataTable , which have a checkboxes for 1st column, EDIT button.
==> Now i check 2 checkboxes and click on EDIT button. Onclick my data process and i want to reset all the checkboxes which are set. Below is onclick function.
==> But $('input[type="checkbox"]', table.cells().nodes()).prop('checked',false); is unchecking only in UI. i.e this time i check row 3 and 4. When i fetch the selected ids, instead of returning [3, 4] it returns [1,2,3,4]
Hi @DeepaMGMG ,
With live.datatables.net, you can create the scenario still, with the data in
data
, something like this.Cheers,
Colin
https://jsfiddle.net/4se305dt/10/
Please have a look here
I think it would work better to use the Gyrocode Checkboxes API. This way that plugin will keep track of the checkbox state. Something like this:
https://jsfiddle.net/makj8wo2/
Kevin
This is what i needed. Helped a lot. Thank you @kthorngren and @colin