JS:数据表多行消息

时间:2018-11-10 10:33:34

标签: javascript datatables

您好,我正在寻找一个js代码,在导出到PDF时可以在其中添加多行消息

$(document).ready(function() {
var printCounter = 0;

// Append a caption to the table before the DataTables initialisation
$('#example1').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'copy',
        {
            extend: 'pdf',
            footer:true,
            message:'this is line1',
            title: 'This is title',
            orientation: 'landscape',
            messageTop: 'The information in this table is copyright to Sirius Cybernetics Corp.',


        },
        {
            extend: 'pdf',

            messageBottom: null
        },
        {
            extend: 'print',
            messageTop: function () {
                printCounter++;

                if ( printCounter === 1 ) {
                    return 'This is the first time you have printed this document.';
                }
                else {
                    return 'You have printed this document '+printCounter+' times';
                }
            },
            messageBottom: null
        }
    ]
} );

});

我想知道如何在pdf文件中添加更多message:

1 个答案:

答案 0 :(得分:0)

正如您在此处看到的https://datatables.net/reference/button/pdf message:已过时。使用messageBottom:messageTop:

多行很容易。像

一样使用\r\n
messageBottom: function() {
    return '\r\n this is the first line preceeded by an empty line' +
           '\r\n this is the second line' +
           '\r\n \r\n this is the third line preceeded by an empty line';
}