3
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>
<script src="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>
<link href="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>
<button id="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 to the export button so that when the user clicks this button, already opens the download window to download in *.csv, the contents of Datatable, in the user’s PC.
How do you resolve?
In jsfiddle it worked, but after making all the imports and everything and putting according to what is in jsfiddle posted, also did not solve
– Tiago Ferezin
@Tiagoferezin , opa .. which version of Datatables are you using ? and it is very important to check the javascript import sequence :)
– Brunno
@Tiagoferezin if you want to download with the imported references, I made available to you here hope it helps :)
– Brunno
spun but it generated a boot, I wanted to put this function inside my button I already customized, got how.? If not, would there be another way to do this? even if it is on the Server side with Java itself.
– Tiago Ferezin
And worse than generating the boot, it has disfigured all my Datatables, and now?
– Tiago Ferezin
@Tiagoferezin, it is only possible to use the buttons generated by the library, because the buttons "Copy", "CSV", "Excel" and "PDF" were implemented using Adobe Flash. The problem of disfigurement must be some conflict with the css files, just remove the new ones and add the old ones :)
– Brunno