I have the following button:
$(document).ready(function() {
$('#example').DataTable({
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "/swf/copy_csv_xls_pdf.swf"
}
});
});
<script src="https://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script><scriptsrc="https://cdn.datatables.net/1.10.2/js/jquery.dataTables.js"></script>
<link href="https://cdn.datatables.net/1.10.2/css/jquery.dataTables.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="http://www.datatables.net/release-datatables/extensions/TableTools/js/dataTables.tableTools.js"></script><linkhref="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script><buttonid="btnExportar">Exportar</button>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nome</th>
<th>E-Mail</th>
<th>Profissão</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Nome
</th>
<th>
E-Mail
</th>
<th>
Profissão
</th>
</tr>
</tfoot>
<tbody>
<td>Tiago Ferezin</td>
<td>[email protected]</td>
<td>Programador</td>
</tbody>
</table>
As we see in the code the function is not working, I do not know the reason, and I would like to associate this function with the export button so that when the user clicks this button, it already opens the download window to download in * .csv, DataTable content, on the user's PC.
How do I resolve it?