Click here to Skip to main content
15,940,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a dynamic jquery data table which has check boxes it. when a check box is checked at header all the check boxes in rows are also checked. i have some rows which are disabled. when the check all option is checked i don't want the disabled checkbox to be checked. Below is the code to check and uncheck all the textboxes

What I have tried:

JavaScript
function CheckUncheckAll() {
         $("#table thead ").on("click", 'input[type="checkbox"]', function () {
             if (!this.disabled) {
                 $('#table tbody chktransid').prop("checked", false);
             }
             if (this.checked) {

                 $('#table tbody input[type="checkbox"]').prop("checked", true);
             } else {
                 $('#table tbody input[type="checkbox"]').removeAttr("checked");
             }
         });
Posted
Updated 17-Mar-16 20:43pm
v2

1 solution

Try this


JavaScript
$(function () { CheckUncheckAll() });

        function CheckUncheckAll() {
            $("#table thead ").on("click", 'input[type="checkbox"]', function () {  
                $('#table tbody input[type="checkbox"]:not(:disabled)').prop('checked', this.checked);
            })
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900