每当我添加dom和按钮时,我的搜索和“显示x条目”都会消失,从而破坏数据表。我似乎无法弄清楚我缺少什么来显示打印按钮。
调试:http://debug.datatables.net/ireroh
JS:
$(document).ready(function() {
$('#dataTables-example').DataTable({
dom: 'Bfrtip',
buttons: [
'print'
]
"sPaginationType": "full_numbers",
"columnDefs": [
{ "searchable": false, "targets": [0, 1] }
]
});
});
<script src="../bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="../bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
答案 0 :(得分:2)
你需要添加数据库按钮js文件..
https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js //cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js
https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css
了解更多信息,请查看以下内容。
https://datatables.net/extensions/buttons/examples/print/simple.html
答案 1 :(得分:0)
你必须这样写,首先加载脚本文件;
<script src="../bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="../bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
dom: 'Bfrtip',
buttons: [
'print'
]
"sPaginationType": "full_numbers",
"columnDefs": [
{ "searchable": false, "targets": [0, 1] }
]
});
});