表格排序下载为csv

时间:2015-02-09 07:05:15

标签: 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错误。该功能似乎完成,但没有下载发生。

1 个答案:

答案 0 :(得分:1)

您正在分配

$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并添加上述表格。