Table 排序下载为 csv
Table Sorter download as csv
我正在尝试将已排序的 table 中过滤后的内容下载为 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 是传递给 table 排序器的 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 并添加上面的。
我正在尝试将已排序的 table 中过滤后的内容下载为 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 是传递给 table 排序器的 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 并添加上面的。