Working with TextWrap in Tabulator

Hi I am a starter with Panel, and trying to render a DataFrame, where one of the fields is a potentially long text. The text field does not wrap as of now, and I have tried the solution here.

With the latter I get a warning:

WARNING:param.Tabulator00158: Setting non-parameter attribute formatter={'TEXT': {'formatter': 'textarea'}} using a mechanism intended only for parameters

Here is a short snippet that hopefully shows the incident:

tabulator_formatters = { 'TEXT': {'formatter': 'textarea'}} 
                                         
edit_table = pn.widgets.Tabulator(df.head(10), 
                                  layout='fit_data_fill',
                                  sizing_mode='stretch_width',
                                  formatter=tabulator_formatters)

edit_table

‘TEXT’ above, is the column containing the long texts.

I think you are missing an s at the end of formatters.

1 Like

Thanks you were right, the linter apparently didn’t work and of course didn’t know the correct name. Has to also write 'TEXT': {'type': 'textarea'}, instead of ‘TEXT’: {‘formatter’: ‘textarea’}.

The following now works

tabulator_formatters = { 'TEXT': {'type': 'textarea'}} 
                                         
edit_table = pn.widgets.Tabulator(df.head(10), 
                                  layout='fit_data_fill',
                                  sizing_mode='stretch_width', # it adds paging!
                                  formatters=tabulator_formatters)

Thanks, textarea this works fine.

Is there any way to set a max_height and abreviate long texts with ellipsis (…) ?

Hi @ljilekor1

Please open a new post with your question. It helps create a better knowledgebase for the community and its simpler to reply to.