Add the export button in html - static
Add the export button in html - static
I want to add the export to excel or pdf buttons in the html rather than it getting generated from the js.
Eg code below:
now the script generates the buttons in the bottom of the table i want to write the buttons in the html
my js :
$(document).ready(function() {
    $('#aa').DataTable( {
        dom: 'frtipB',
        buttons: [
            'excelHtml5' 
         ]
    } );
    
} );
my html :
<div>
<table id="aa" cellspacing="0" width="100%">
      <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
<tbody>
    <tr>
            <td>Tiger Nixon</td>
        <td>System Architect</td>
        <td>Edinburgh</td>
        <td>61</td>
        <td>2011/04/25</td>
        <td>$320,800</td>
    </tr>
    <tr>
        <td>Garrett Winters</td>
        <td>Accountant</td>
        <td>Tokyo</td>
        <td>63</td>
        <td>2011/07/25</td>
        <td>$170,750</td>
    </tr>
</tbody>
</table>
</div>
Like I want to be able to write
<div class="dt-buttons"><a class="dt-button buttons-excel buttons-html5" tabindex="0" aria-controls="aa">
<span>Excel</span>
</a>
</div> 
directly into the html, it only shows the button but doesn't work.
This discussion has been closed.
            
Answers
Your best bet would be to use the
buttons()api. I wanted to use a lot of the buttons (colvis,copy,select,print, etc etc), but I wanted them to show up in a div that would slide out from the left of the screen.Screenshots: http://d.pr/i/EnPN & http://d.pr/i/PrTJ
They're all DataTables buttons, and I used the
button()api. Heres my code, Ill leave as much of it in there as I can so you can get an idea of how to use it..