Thomas Johnson Thomas Johnson - 1 year ago 162
Javascript Question

Call DataTables export functions from JavaScript

The DataTables buttons extension allows users to export the table data to CSV, Excel, etc. There are examples in the documentation that show how to style the button elements.

What I want to do though is to be able to call the export functions from menu buttons in a Floating Action Button. I could move and restyle the DataTables buttons every time the data table gets redrawn, but is there an easier way?

In particular, is there a way to call the export functions directly from JavaScript?

Answer Source

Couple what @DelightedD0D said in his comment:

You could always just do

$('#floatingBtn').click(function(){ $('#someExportBtn').click(); });

... with some CSS to force the original buttons out of view off-screen and you'd wind up with only one set of buttons being shown.

.buttons-html5, .buttons-print {
    position: absolute;
    left: -9999px;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download