0

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.

Rajaram Shelar
  • 7,537
  • 24
  • 66
  • 107

2 Answers2

6

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 :

enter image description here

davidkonrad
  • 83,997
  • 17
  • 205
  • 265
  • Thanks for the response. I have reverted the changes as per your suggestions. But still facing the same issue – Rajaram Shelar Aug 19 '13 at 11:08
  • I have the same problem only the Copy button does work, the saving does nothing – Stuart Dobson Feb 20 '14 at 11:31
  • 1
    Remember to check your F12 console for any errors this will tell you if your swf path is correct – Stuart Dobson Feb 20 '14 at 11:33
  • I don't even see any tires in the F12 Network traffic which would even try to read the swf. – Csaba Toth Oct 09 '14 at 19:47
  • hey @CsabaToth, It is impossible for me to figure out what exactly your problem is without seeing the code :) Bear in mind this is a rather old answer, targeting dataTables 1.9.x and local based `.swf`. Typically I see people have problems with the `.swf` because they use a relative path. The fact that you dont see the `.swf` in the network console could indicate that. Try use the dataTables CDN -> **http://cdn.datatables.net/tabletools/2.2.3/** (CDN links to the `.swf` files is near bottom of the page) – davidkonrad Oct 09 '14 at 20:03
  • All right: I got the swf path right, but my FF didn't have the Flash plugin installed. That was my problem. Thanks for the reaction David though – Csaba Toth Oct 09 '14 at 20:38
  • i have same problem... my print button in working only another are not working. – Karan May 05 '15 at 12:17
  • @KaranRajput, this is a very old answer. It sounds like you either have a wrong path for the .swf or that flash is not enabled in your browser (this is the most typical reason today). If flash is enabled, try using the .swf from the CDN -> http://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf – davidkonrad May 05 '15 at 12:27
3

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.

Ike
  • 1,194
  • 12
  • 18
  • This. And it wasn't enough just to show-initialize-hide. I had to do a setTimeout 200 to make it work. Not pretty. – frnhr Apr 03 '14 at 05:46
  • Same for me. For some reason if the table is initially hidden the buttons won't work even after its been shown. – Bill Garrison Feb 12 '15 at 20:57