Cells with paragraphs. How to keep the paragraphs and not merge them?

Cells with paragraphs. How to keep the paragraphs and not merge them?

CapamaniaCapamania Posts: 233Questions: 81Answers: 5
edited April 2016 in Editor

How can I prevent a paragraph to merge?

I have paragraphs in some of the cells in my editor table (serverside). So something like this:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

In mysql the paragraphs still exist. In the table in the frontend the result is this though:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet

How can I keep the paragraphs in the editor table in the frontend as well?

Edit: I just found this: https://www.datatables.net/forums/discussion/845/line-breaks-paragraphs-etc-in-table-cells

How can I "If server-side, then you could just insert a blank set of TR / TD elements where needed by parsing through the result set."?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You need to format it using HTML. This is true in any HTML document and not just DataTables. White space is more or less meaningless in HTML.

    One option would be use to columns.render to add the required line breaks:

    render: function ( data, type, row ) {
      return data.replace(/\n/g, '<br>');
    }
    

    If you want to use p tags you'd need to use something a little more complex.

    One other option is to use the white-space option in CSS. Seeing it to white-space: pre-wrap should do it I think.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    This did the magic. Excellent. Thanks a lot!

This discussion has been closed.