JQuery 数据表中的 TableTools 导出不起作用 [英] TableTools export in JQuery Datatables not working

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

问题描述

我已经为此苦苦挣扎了两天.我已经在数据表论坛上发帖了,但没有得到任何回应,所以我希望这里的社区可以提供帮助.我在这里阅读了有关此问题的类似帖子,但我已经按照许多帖子的建议使用了正确的 sSwf 路径.

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>

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

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

推荐答案

您的代码是正确的并且与 TableTools 示例.该问题与加载外部 SWF 文件有关,在 <iframe> 中加载代码时它不起作用(如在您的 JSFiddle 示例) 或由于安全限制使用 file:// 协议从计算机上的文件加载时.

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.

或者,如果您希望它在您的计算机上本地运行,您需要使用 copy_csv_xls_pdf.swf 的相对路径.例如,将 copy_csv_xls_pdf.swf 与您的页面一起保存并使用 "sSwfPath": "copy_csv_xls_pdf.swf".

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".

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

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