Checkbox problem with data table
Checkbox problem with data table
saudagarrizwan
Posts: 8Questions: 1Answers: 0
Am using datatables in my project. I have a checkbox on each row and contains paging and sorting. I am getting all the records at once. When I checked on check all it check all the check boxes. Am using the below code
[code]
$('#check_all').click( function(e) {
var chkAll = $("#check_all").is(':checked');
if(chkAll) $('input', oTable.fnGetNodes()).attr('checked', this.checked);
else $('input', oTable.fnGetNodes()).removeAttr('checked');
});
[/code]
When I uncheck and check again it does not checks the check boxes. But when do inspect element will see a property checked="checked", but check box is not showing as checked.
Conclusion: If we select check box first time and then uncheck it and then do check all. Earlier checked checkboxes will not work.
Can you please help me in this.
[code]
$('#check_all').click( function(e) {
var chkAll = $("#check_all").is(':checked');
if(chkAll) $('input', oTable.fnGetNodes()).attr('checked', this.checked);
else $('input', oTable.fnGetNodes()).removeAttr('checked');
});
[/code]
When I uncheck and check again it does not checks the check boxes. But when do inspect element will see a property checked="checked", but check box is not showing as checked.
Conclusion: If we select check box first time and then uncheck it and then do check all. Earlier checked checkboxes will not work.
Can you please help me in this.
This discussion has been closed.
Replies
Try changing attr to prop