javascript - 表排序器下载为 csv

标签 javascript jquery tablesorter

我正在尝试从排序表中将过滤后的内容下载为 csv 文件。我正在从 here 中获取示例.

但是,当我尝试以下代码时,什么也没有发生。我在这里做错了什么吗。

$("#download").click(function(){
    wo = $("#table1")[0].config.widgetOptions;
    wo.output_separator = ',';
    wo.output_delivery = 'd';
    wo.output_saveRows = 'f';
    wo.output_saveFileName = 'myTable.csv';
    $("#table1").trigger('outputTable');
    return false;
    });

table1 是传递给表排序器的 id。

编辑:firebug 中没有 javascript 错误。该功能似乎可以正常完成,但没有下载。

最佳答案

你正在分配

$wo = $("#table1").config.widgetOptions;

然后使用 wo 获取更多方法。您应该使用 wo$wo

我在我的代码中添加了这些 js 文件,现在可以正常工作了:

 <script src="http://mottie.github.io/tablesorter/js/jquery.tablesorter.js"></script>
 <script src="http://mottie.github.io/tablesorter/js/widgets/widget-output.js"></script>
 <script src="http://mottie.github.io/tablesorter/js/jquery.tablesorter.widgets.js"></script>

删除任何其他 tablesorter js 并添加上面的。

关于javascript - 表排序器下载为 csv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28404442/

相关文章:

javascript - React Redux 用于 react 路由器导航的加载栏

javascript - 当元素出现在屏幕上时如何启动动画?

jquery - 如何忽略CSS类

javascript - jQuery - 使具有固定标题的表格可排序

javascript - 在 d3 图中的 <g> 元素上触发悬停事件

javascript - Node.js 简单代理服务器

jquery - 将父 DIV 高度调整为内部内容(RSS 提要)

javascript - toggle ("slide", {direction : "right"}, 5000) parent div问题的高度

html - Bootstrap : 100% height div inside a th with rowspan

jquery - tablesorter寻呼机初始分页