TableTools plugin export buttons are not working

浪尽此生 提交于 2019-11-29 18:11:48

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!