SelectAll + disable other button
SelectAll + disable other button
Hi, I'm using the datatables built in selectAll button and I want it to select all rows AND disable the delete button I have added to the page. I'm using this code:
`var table = $('#data-table-combine').DataTable();
var buttons = new $.fn.dataTable.Buttons(table, {
buttons: [
{ extend: 'selectAll', text: 'Select All Rows', action: function (e, dt, button, config) { document.getElementById('btnDelete').disabled = true } },
`
This allows the Select All Rows button to disable the Delete button but it will not select all rows. If I remove the action: function() then it does select the rows. Isn't it possible to do both? Or is there something wrong with my code?
Any help is greatly appreciated!
Answers
You will probably need to do something like the last example in the
buttons.buttons.action
docs to execute the selectAll default action after executing the disable button code.Kevin
Thank you for your help. That makes sense however, a user could possibly still select all rows manually and get around that. Is there a way to disable the Delete button when all rows are selected? I tried both options below but can't get it to work.
Its hard to say without seeing exactly what you are doing. Your first code snippet seems to work here:
http://live.datatables.net/yemowara/1/edit
In order for us to help debug please post a link to your page or a test case replicating the issue.
Kevin
Thank you. If needed I will create a test case for further help