jQuery dataTables : Export with newline / break in cell, using jQuery

不打扰是莪最后的温柔 提交于 2019-12-11 08:32:30

问题


I´m trying to generate an exportable datatable with the plugin "jquery.dataTable".

But for design reasons I need linebreaks inside the cells. For the HTML view I simply use <br>, but if I try to export this f.e into a PDF, it will cause to break the output from the first occurring br, so I googled around and tried to pre-process the data and replace breaks with newline characters but this will cause the PDF export to break at the first br for even a lot of rows. I have no idea.

Here's the relevant part of my attempt:

{
    "aButtons": [{
        "sExtends": "pdf",
        "fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
            return sValue.replace(/<br\s*\/?>/ig, "\r\n") ;
        },
        "sNewLine":"\r\n"
    }]
},

来源:https://stackoverflow.com/questions/20934876/jquery-datatables-export-with-newline-break-in-cell-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!