DataTable: fit columns + horizontal scrollbars?

How can I achieve the following for a DataTable?

  • Colum width is calculated based on the cell content (also considering the column name)
  • table width/viewport is still respected → horizontal scrollbars are introduced if the columns are getting too wide.

The autosize_mode argument only seems to support adjusting the viewport (via "fit_viewport") or forcing all columns inside the viewport (via "fit_columns"). In both cases no horizontal scrollbars are available.

I thought that was what fit_columns was supposed to do, so maybe open a GitHub Issue with full details.

I have had a similar problem since I updated to bokeh 3 where if I use fit_viewport or fit_columns the table doesn’t render at all. There is an open github issue related to this here:

For now what I found working is to specify the width for every column and use autosize_mode='none' for the DataTable.

lol I just saw that the github issue I mentioned was opened yesterday by the OP. This is the issue I meant to share:

Unfortunately that is not the case and the document mentions that there won’t be a horizontal scrollbar. So it seems like there is a feature gap.

"fit_columns"

Compute column widths based on cell contents but ensure the table fits into the available viewport. This results in no horizontal scrollbar showing up, but data can get unreadable if there is not enough space available.

So it seems like there is a feature gap.

Issue still seems appropriate then.

1 Like