【问题标题】:Data table not show print数据表不显示打印
【发布时间】:2017-12-09 16:00:54
【问题描述】:

当我写“”

print

 "$(function () {
        $("#example1").DataTable(
            {
                dom: 'Bfrtip',
                buttons: [
                    {
                        extend: 'print',
                        text: 'Print current page',
                        autoPrint: false
                    }]
            }
        );
        $("#structure_field-add-form").validate({});
    });"

这不会让打印按钮显示来使用它,请问我该如何解决这个问题?像图片一样输出

【问题讨论】:

  • 你进出双引号,破坏了字符串。我很惊讶您没有收到语法错误。
  • no no 在实际代码中我没有双引号 $(function () { $("#example1").DataTable( { dom: "Bfrti", buttons: [ "print"] } ); $("#structure_field-add-form").validate({}); });

标签: php laravel-5 datatable datatables


【解决方案1】:

你把所有需要的 JS 文件都放好了吗?

请检查此链接。 https://datatables.net/extensions/buttons/examples/initialisation/simple.html

你必须添加以下JS文件。

https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js
//cdn.datatables.net/buttons/1.3.1/js/buttons.flash.min.js
//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/pdfmake.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/vfs_fonts.js
//cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js
//cdn.datatables.net/buttons/1.3.1/js/buttons.print.min.js

另外请检查以下代码。这是我在项目中使用的数据表按钮的工作示例。

var table1 =  $('#task-table').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'csv','excel','selectAll','selectNone',
            {
                extend: 'copy',
                text: 'COPY ALL',
                className: 'pull_right',
                exportOptions: {
                    modifier: {
                        page: 'all'
                    }
                }
            }
        ],
        columnDefs: [ {
            orderable: false,
            className: 'select-checkbox',
            targets:   0,
            checkboxes: {
                'selectRow': true
            }
        } ],
        select: {
            style:    'multi',
            selector: 'td:first-child'
        },
        order: [[ 1, 'asc' ]],
        "iDisplayLength" : 20,
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    相关资源
    最近更新 更多