gyrocode / jquery-datatables-checkboxes

Checkboxes is an extension for the jQuery DataTables library that provides universal solution for working with checkboxes in a table.
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
MIT License
150 stars 61 forks source link

Remove header checkbox clickable in datatables-checkboxes. #93

Closed virenbpanchal closed 5 years ago

virenbpanchal commented 5 years ago

Hello,

How to remove checkbox from header of a datatable. I have tried below changes in CSS. Though cursor is not allowed, it still clickable and selects all records.

table.dataTable thead th.dt-checkboxes-select-all {
    cursor: not-allowed;
}
table.dataTable thead th.dt-checkboxes-select-all input[type="checkbox"] {
    display: none;
}

Thank you very much for all your time and effort you have put for this awesome jquery-datatables-checkboxes. It really helps.

mpryvkin commented 5 years ago

Try setting columns.checkboxes.selectAll option to false to disable “select all” control in the header.

virenbpanchal commented 5 years ago

Thanks for your reply. Below solution works as you suggested.

//Below prevents click action on select-all checkbox in Header.
$('.dt-checkboxes-select-all').click(false);

Also I have make following changes to CSS to disappear Checkbox in header.

table.dataTable thead th.dt-checkboxes-select-all {
    cursor: not-allowed;
}
table.dataTable thead th.dt-checkboxes-select-all input[type="checkbox"] {
    display: none;
}
nickpapoutsis commented 4 years ago

@virenbpanchal That's not the right solution (even though it kinda works).

Just use columns.checkboxes.selectAll like this:

 'columnDefs': [
      {
         'targets': 0,
         'checkboxes': {
              selectAll: false
         }
     }
 ]

This simply disables the checkbox in the header and doesn't require any CSS or other code to make it work or look good.