我正在尝试从排序表中将过滤后的内容下载为 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/