How to hide check all, clear all checkbox
Posted
by Kalpana
on Stack Overflow
See other posts from Stack Overflow
or by Kalpana
Published on 2010-03-09T04:59:02Z
Indexed on
2010/03/09
5:06 UTC
Read the original article
Hit count: 505
jQuery
|JavaScript
I am having check box in the column header. The function of this is to check or uncheck all the check boxes in that column.If the row check box is checked and say delete, that row can be deleted from the dataTable.
If the row object is used in some other table as a foreign key i put '-' in that row instead of check box which indicates that row cannot be deletable.
In these cases if all the row has '-" , there is no need to have the header check box. How to programatically hide this 'Check All | Clear All' check box, if there is nothing to be removed.
It would be even preferable to hide the 'Remove' button if there is no selection to be made.
What are the best practices to address the above scenario. I have attached the javascript which I am using.
<script type="text/javascript">
var tableId = '#user\\:userList';
jQuery(document).ready(function() {
jQuery('#selectAll').click(function() {
jQuery(tableId).find("input[type='checkbox']").attr('checked', jQuery('#selectAll').is(':checked'));
});
});
</script>
© Stack Overflow or respective owner