Disable Export Button if no Rows Selected
Disable Export Button if no Rows Selected
I am using the button and bootstrap plugins to add a CSV export button to my table. It currently uses the 'selected: true' configuration in the button's modifier initialization. I only want it to export the rows that are selected by the user (which is currently does fine). Is there anyway to automatically disable/enable the button based on whether any rows are selected, similar to how a button behaves when it extends 'selected'.
Alternatively, is there a setting so that if no rows are selected it will export the whole table instead of an empty csv file?
This question has an accepted answers - jump to answer
Answers
use the "select" and "deselect" event handlers and then
https://datatables.net/reference/api/button().disable()
"button().disable()" or "enable()"
If you want to export the whole table if nothing is selected use exportOptions with this modifier:
https://datatables.net/reference/api/buttons.exportData()