I presume that the user input has new line characters (\n) for the line breaks, and you want to show them as multiple lines? If so, a rendering function would be the way to do it - e.g.:
Thanks, it works. Display in cell on multiple lines.
But it is a problem. If I export to pdf or excel or want to print, the display in the cell is on one line.
Please help me.
When exporting the export function uses the displayorthogonal data by default. You can use a different orthogonal data as shown in this example.
PDF uses \n for newlines. You will need to use orthogonal data to return the original data with \n.
Excel is more complicated. You will need to set the cell to use word wrap as discussed in this thread. Plus you will need to use the Excel CHAR function to replace the newline character with CHAR(10). See this thread for some details.
Answers
I presume that the user input has new line characters (
\n
) for the line breaks, and you want to show them as multiple lines? If so, a rendering function would be the way to do it - e.g.:Allan
Thanks, it works. Display in cell on multiple lines.
But it is a problem. If I export to pdf or excel or want to print, the display in the cell is on one line.
Please help me.
I found the solution here: https://datatables.net/forums/discussion/34951/how-to-include-line-breaks-when-printing
For PRINT it works (stripHtml: false).
It does not work for PDF or Excel export (stripNewlines: false).
When exporting the export function uses the
display
orthogonal data by default. You can use a different orthogonal data as shown in this example.PDF uses
\n
for newlines. You will need to use orthogonal data to return the original data with\n
.Excel is more complicated. You will need to set the cell to use word wrap as discussed in this thread. Plus you will need to use the Excel CHAR function to replace the newline character with
CHAR(10)
. See this thread for some details.Here is an example with Print, Excel and PDF:
https://live.datatables.net/socehike/1/edit
Kevin
Thanks.