Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Check all" Checkbox in thead doesn't work with stickyHeaders in 2.10.8 #350

Closed
ptepper opened this issue Jul 3, 2013 · 1 comment
Closed

Comments

@ptepper
Copy link

ptepper commented Jul 3, 2013

Hi,

You posted some code to solve this problem here:
#261

but it has stopped working since the upgrade. Now, when you scroll down and click the header checkbox in the cloned/sticky header, it tries to sort the table and breaks sorting on other columns.

It has something to do with the .trigger('change')

called here:

doChecky = function(c, col){
    $table.find('tbody tr td:nth-child(' + (parseInt(col,10) + 1) + ') input').each(function(){
        this.checked = c;
        $(this).trigger('change');
    });
};

but I haven't figured out what the problem is yet. It should not be sorting when the header checkbox is clicked.

@ptepper
Copy link
Author

ptepper commented Jul 3, 2013

Nevermind, I figured it out and it's very simple. I was using .attr('checked','checked') and I should have been using .prop('checked', true) because I'm using jQuery 1.9.1.

If anyone is interested all you need to do is add a class to the checkbox in the header (e.g. "checkAll") and add a class to all the checkboxes in the table (e.g. "rowCheck"). Then do this:

$(document).on("click",".checkAll",function(){      
    if($(this).is(":checked")){     
        $(".rowCheck,.checkAll").prop('checked', true);             
    }
    else{
        $(".rowCheck,.checkAll").prop('checked', false);        
    }   
})

You need to check the checkAll boxes also, otherwise it won't keep the two different header checkboxes in sync (sticky and original).

@ptepper ptepper closed this as completed Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant