2

I have a column filled with text in tabulator. The text is displayed with line breaks.

{title:"Title", field:"title", formatter:"textarea"},

enter image description here

When I introduce the built in URL formatter, the text in the first column does not break anymore.

  {title:"Title", field:"title", formatter:"textarea", formatter:"link", formatterParams:{target:"_blank", urlField:"source"}},

enter image description here

Is there a way to introduce link while keeping the linebreaks?

Stücke
  • 493
  • 3
  • 6
  • 24

2 Answers2

3

By default, tabulator renders the cells with "white-space: nowrap" (as defined in CSS class tabulator-cell in tabulator.css).

The formatter "textarea" overrides that by manually setting "pre-wrap" on the style of the cell element: modules/format.js

Options:

  1. Write a custom formatter (to render a link with "white-space: pre-wrap")
  2. Add your own CSS (after tabulator.css, to make sure the css cascade works) to target links inside tabulator-cell to set "white-space: pre-wrap". This should work:
    .tabulator-row .tabulator-cell a {
        white-space: pre-wrap;
    }
    
Christian Heine
  • 256
  • 1
  • 8
1

http://tabulator.info/docs/4.0/format#format-height

Variable Height Formatters

By default formatters will keep their contents within the height of the current row, hiding any overflow. The only exception to this is the textarea formatter which will automatically vary its height when the column is resized so its contents does not overflow.

If you would like this functionally to appear in another type of formatter you can set the variableHeight property to true in the column definition and it will will behave in a similar way to the textarea formatter:

{title:"Name", field:"name", formatter:myCustomFormatter, variableHeight:true}

also you can not set multiple formatters at once , that is wrong:

{title:"Title", field:"title", formatter:"textarea", formatter:"link", formatterParams:{target:"_blank", urlField:"source"}}
-                              ^^^^^^^^^ overriden by ^^^^^^^^
Dimava
  • 638
  • 4
  • 6
  • Thank you very much for your answer! When I remove `formatter:"textarea"` and introduce `variableHeight:true` there is still no line breaking. – Stücke Dec 16 '19 at 15:36