![](/img/trans.png)
[英]why is this dataTables jQuery plugin (TableTools) not working?
[英]jQuery dataTables tabletools not working
我正在嘗試通過以下配置使用數據表表格工具。 我看不到下面定義的表格工具按鈕。 我想念什么嗎? 請告訴我。
var oTable = $('#dashboard')。dataTable({“ bPaginate”:true,“ bLengthChange”:false,“ bFilter”:true,“ bSort”:false,“ bInfo”:false,“ bAutoWidth”:false, “ sPaginationType”:“引導程序”,“ aoColumnDefs”:colHeaders,
"oTableTools": {
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy to clipboard"
},
{
"sExtends": "csv",
"sButtonText": "Save to CSV"
},
{
"sExtends": "xls",
"sButtonText": "Save for Excel"
}
]
}
});
設置sDom參數
像這樣:
"sDom": 'T<"clear">lfrtip'
更多信息: http : //datatables.net/release-datatables/extras/TableTools/index.html
就像@Dylan Slabbinck所說的那樣,您必須設置“ sDom”參數,但還必須在項目目錄中設置“ sSwfPath”。 盡管進行了這些更改以及所顯示的代碼,但這可能還不夠。 我建議您初始化除TableTools Buttons部分之外的表,並在實例化后設置按鈕及其配置。
"sDom": 'T<"clear">lfrtip' //inside your table configuration
TableTools.DEFAULTS.sSwfPath = "your path";
// mine was TableTools.DEFAULTS.sSwfPath = "<?php echo $this->basePath() ?>/swf/copy_csv_xls_pdf.swf";
TableTools.DEFAULTS.aButtons = ["xls", "copy", "csv"];
TableTools.BUTTONS.xls.sButtonText = "Save for Excel";
TableTools.BUTTONS.copy.sButtonText = "Copy to clipboard";
TableTools.BUTTONS.csv.sButtonText = "Save to CSV";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.