Mozart
February 25, 2014, 12:21pm
#1
Hi, I’ve added a checkbox in the header section like this:
mygrid.attachHeader(" ,<input type='checkbox' id='checkbox'>, ");
But I can’t get the checkbox to work with my code.
$("#checkbox").change(function() {
if(this.checked) {
alert("checked");
}else{
alert("unchecked");
}
});
If I put the checkbox outside of the header it works fine.
Is there a way to fix this? Or am I not meant to put custom code in header? I’ve also noted that if I click the current checkbox it sorts the column which I don’t want.
Thank you.
Mozart
February 27, 2014, 3:24pm
#2
There’s really no way to achieve this?
sematik
February 27, 2014, 4:15pm
#3
Please, make sure that you attach the event after the init of the grid.
The following code works well for us:
document.getElementById("checkbox").onchange=function() {
if(this.checked) {
alert("checked");
}else{
alert("unchecked");
}
};
Mozart
February 27, 2014, 5:25pm
#4
Thank you. At least I understand why it wasn’t working now.
It is called after the init() method, but still no luck. Adding a timeout before loading the function resolved the problem though. Thank you!