I am using TableTools for export functionality but it is not working. Only print buttin working and shows pop up and hide. I have got suggestions from this thread but did not given clear idea to me. Below is my implementation
$('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "copy_csv_xls_pdf.swf"
}
});
I have kept .swf file in the same folder where my server page is exist. Also I tried with "sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
. But not worked for me. Also I got suggestion that there is some security setting of the flash player which need to configure. Is flash player required for using this functionality?. Or what is going wrong in the implementation. Please suggest.
Two important rules :
1) You must include the TableTools-script, eg
<script type="text/javascript" src="DataTables-1.x.x/extras/TableTools/media/js/TableTools.min.js"></script>
DataTables-1.x.x/
= your path to your version of datatables.
2) The fact that only the print-button works strongly suggest your .swf
-path is wrong. Print is done in javascript by datatables itself - copy, excel etc is done by the flash-plugin.
Dont ever change the path for the .swf
!! Let the .swf
stay where it is, eg
sSwfPath: "DataTables-1.x.x/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
There is no security issues or other prerequisities needed for the TableTools export functions to work. It should work right out of the box.
When you have ensured 1) and 2) this simply initialization
var table = $('#example').dataTable({
sDom: 'TC<"clear">lfrtip',
oTableTools: {
sSwfPath: "DataTables-1.x.x/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
}
});
will produce a datatable with fully functional export-buttons :
I've come across this problem. My situation is like this. Everything seems working fine. the buttons are there. The only thing is that the buttons don't work.
My problem is that the table that is supposed to be exported is in a tabbed div view. And this div view is not visible initially. It can only be visible after user clicks on the tab it is in.
Solution: Place the table on the very first visible tab and everything works fine. It is still mysterious to me but it works. Hope it helps.
来源:https://stackoverflow.com/questions/18206345/tabletools-plugin-export-buttons-are-not-working