【发布时间】: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 的路径?