TableTools导出在JQuery Datatables中不起作用 [英] TableTools export in JQuery Datatables not working

查看:154
本文介绍了TableTools导出在JQuery Datatables中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力两天。我已经发布在数据表论坛上,但我没有回复,所以我希望这里的社区可以帮助。
我已经在这个问题上看过类似的帖子,但是我已经在sSwf中使用了正确的路径。许多帖子都表示。



导出按钮出现,所有资源都被加载。但是,单击按钮没有任何操作。控制台上没有错误。

 < script> 
$(document).ready(function(){
$('#example')。DataTable({
dom:'T<clear> lfrtip',
tableTools:{
sSwfPath:http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf
}
});
});
< / script>

这是一个包含我的代码的JSFiddle:
http://jsfiddle.net/h2bof5cr/2/

解决方案

您的代码是正确的,并符合 TableTools示例该问题与加载外部SWF文件相关,当代码在< iframe> 中加载时不起作用(如 JSFiddle示例)或从您的计算机上的文件加载时使用 file:// protocol due对于安全限制。



解决方案是将您的代码上传到Web服务器,它应该没有任何变化。



或者,如果您希望在计算机上在本地工作,则需要使用相对路径 copy_csv_xls_pdf.swf 。例如将 copy_csv_xls_pdf.swf 与您的页面一起保存,然后使用sSwfPath:copy_csv_xls_pdf.swf。 p>

I've been struggling with this for two days. I've posted on the datatables forum but I've gotten no response so I'm hoping the community here can help. I've read similar posts on this issue here but I'm already using the correct path for sSwf as many posts suggest.

The export buttons appear and all resources are loaded. However, Clicking the buttons has no action. There are no errors on the console.

<script>
$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'T<"clear">lfrtip',
        tableTools: {
            "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"
            }
    } );
} );
</script>

Here is a JSFiddle with my code: http://jsfiddle.net/h2bof5cr/2/

解决方案

Your code is correct and matches the TableTools example. The issue is related to loading external SWF file, it doesn't work when code is loaded in <iframe> (as in your JSFiddle example) or when loaded from file on your computer using file:// protocol due to security restrictions.

The solution is to upload your code to a web server and it should work without any changes.

Alternatively, if you want it to work locally on your computer, you need to use relative path to copy_csv_xls_pdf.swf. For example save copy_csv_xls_pdf.swf along with your page and use "sSwfPath": "copy_csv_xls_pdf.swf".

这篇关于TableTools导出在JQuery Datatables中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆