【发布时间】:2015-10-11 22:17:19
【问题描述】:
我正在尝试为我的页面添加一个“下载为 CSV 文件”按钮,该按钮显示来自数据库的数据。我浏览了他们的论坛,但找不到解决我的错误的方法。
我附上了我得到的错误的屏幕截图以及它指向的代码部分。请帮我解决这个错误。
它所指的代码:
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css">
<script src = "https://cdn.datatables.net/tabletools/2.2.4/js/dataTables.tableTools.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.css">
<script src="jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#leads_table thead th").each (function(){
var title = $("#leads_table thead th").eq( $(this).index()).text();
$(this).html (' <input type = "text" placeholder = "Search '+title+'"/> ');
});
var table = $('#leads_table').DataTable(
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "/swf/copy_csv_xls_pdf.swf"
}
);
table.columns().every(function(){
var that = this;
$( 'input', this.header() ).on ( 'keyup change', function(){
that
.search( this.value )
.draw();
} );
});
});
我不熟悉同时使用 Datatables 和 tableTools。因此,任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery datatables tabletools