我不知道为什么我的数据表导出按钮(导出到excel,PDF,打印,复制)不起作用
我使用此表格datatables.net https://datatables.net/extensions/buttons/examples/initialisation/export.html
这是我的数据表配置:
什么错误?! 执行代码时什么也没给我显示?桌子消失了! dom:“ Bfrtip”, 纽扣: [ 'copy','csv','excel','pdf','print' ]
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.flash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript">
var save_method; //for save method string
var table;
$(document).ready(function() {
//datatables
table = $('#table').DataTable({
"responsive": true,
"processing": true, //Feature control the processing indicator.
"serverSide": true, //Feature control DataTables' server-side processing mode.
"order": [], //Initial no order.
// Load data for the table's content from an Ajax source
"ajax": {
"url": "<?php echo site_url('personcontroller/ajax_list')?>",
"type": "POST"
},
//Set column definition initialisation properties.
"columnDefs": [
{
"targets": [ -1 ], //last column
"orderable": false, //set not orderable
},
],
"pageLength": 25
dom: 'Bfrtip', // this line for export table *********
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
});
</script>
答案 0 :(得分:0)
在pageLength
选项之后,您错过了逗号:
"pageLength": 25,