The demo on the select all doesn't really work. https://datatables.net/extensions/select/examples/initialisation/checkbox.html
What's the best way to implement the select all checkbox after they are created via the columnDef
attributes?
The demo on the select all doesn't really work. https://datatables.net/extensions/select/examples/initialisation/checkbox.html
What's the best way to implement the select all checkbox after they are created via the columnDef
attributes?
This should work for you:
I've added to the CSS though:
Working JSFiddle, hope that helps.
You can use Checkboxes extension for jQuery Datatables.
See this example for code and demonstration.
See Checkboxes project page for more examples and documentation.
You can use this option provided by dataTable itself using buttons.
dom: 'Bfrtip', buttons: [ 'selectAll', 'selectNone' ]'
Here is a sample code
I made a simple implementation of this functionality using fontawesome, also taking advantage of the Select Extension, this covers select all, deselect some items, deselect all. https://codepen.io/pakogn/pen/jJryLo
HTML:
Javascript:
Base on Francisco Daniel's answer I modified some of the Jquery code here's My version. I removed some excess code and use "fa" instead of "far" for the icon. I also remove the "far fa-minus-square" since I can't understand its purpose.
-- Edited --
I added the "draw" event for the button icon to update whenever the table is redrawn or reloaded. Because I noticed when I tried to reload the table using "myTable.ajax.reload()" the button icon is not changing.
https://codepen.io/john-kenneth-larbo/pen/zXeYpz