问题
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