【问题标题】:Datatable Tool options - Excel,CSV,PDF and Copy is not working数据表工具选项 - Excel、CSV、PDF 和复制不起作用
【发布时间】:2014-05-28 20:33:38
【问题描述】:

我下载了 dataTables.tableTools.js 并尝试运行它,但 Excel、CSV、PDF 和复制不起作用,只有打印选项起作用,我按照文档中给出的所有步骤操作。

我可以看到鼠标指针在悬停时发生变化。

$("#_dynamicReportContainer").empty();
var tableDefinition = "<table id='_dynamicReportTable'><thead><tr>";

// do some updates here...

tableDefinition = tableDefinition.concat('</tr></thead></table>');
$('#_dynamicReportContainer').append(tableDefinition);
var table = $('#_dynamicReportContainer').children();

// do some updates here...

reportData.each(function (k, v) {
       table.append("<tr><td>" + startDate + "</td><td>" + queryStringSecondary + "</td><td>" + k + "</td><td>" + v + "</td></tr>");
});

// do some updates here...

$('#_dynamicReportTable').dataTable({ "autoWidth": false, "bInfo": false, paging: false,
    "dom": 'T<"clear">lfrtip',
    "tableTools": {
        "aButtons": ["print", "csv"],
        "sSwfPath": window.location.protocol + "//" + window.location.host + "/_layouts/TimeSheet/js/ui/supportFiles/copy_cvs_xls_pdf.swf"
    }
});

我可以看到表格(数据表)上的数据并且可以打印,但是其他选项(Excel、CSV...)不起作用。

【问题讨论】:

  • 将 sSwfPath 设为绝对路径。
  • 下面也不起作用: $('#_dynamicReportTable').dataTable({ "autoWidth": false, "bInfo": false, paging: false, "dom": 'Tlfrtip', "tableTools": { "aButtons": ["print", "csv"], "sSwfPath": window.location.protocol + "//" + window.location.host + "/_layouts/TimeSheet /js/ui/supportFiles/copy_cvs_xls_pdf.swf" } });
  • 如果您采用生成的路径并尝试在浏览器中加载它,它会加载 .swf 吗?你为什么要构造一个绝对路径,而不是使用你肯定知道指向 .swf 的路径?

标签: jquery-datatables


【解决方案1】:

您可以试试这个:从初始化中删除“sSwfPath”并添加以下代码:

TableTools.DEFAULTS.sSwfPath = "your path";
// mine was TableTools.DEFAULTS.sSwfPath = "<?php echo $this->basePath() ?>/sw//copy_csv_xls_pdf.swf";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 2023-02-04
    • 2019-10-31
    • 2015-07-08
    • 2014-10-22
    相关资源
    最近更新 更多