-1
我想爲我的頁面添加一個「下載爲CSV文件」按鈕,該頁面顯示數據庫中的數據。我已經通過他們的論壇,但無法找到解決我的錯誤。爲現有DataTable初始化tableTools
我附上了他得到的錯誤和它指向的代碼部分的屏幕截圖。請幫我解決這個錯誤。
,它的引用代碼:
<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();
});
});
});
我是新來同時使用數據表和tableTools。所以,任何幫助將不勝感激。
的[數據表下載XLS/CSV文件不能正常工作]可能重複(http://stackoverflow.com/questions/ 29386972/data-tables-download-xls-csv-file-not-working-properly) –
另外還有https://www.datatables.net/extensions/tabletools/ –