Bokeh TableColumns formatting to be at least as wide as the widest row


I am using a DataTable to display a large amount of data but I am running into the issue where the data gets cut off -


It would be great if using the HTMLTemplateFormatter or properties on the DataTable/TableColumn I could make the table take up as much space as it needs.

I’ve tried just setting an arbitrary min-width on the cell itself within the column with:

TableColumn(title=f"<span class=cl1>{col}</span>", field=f"{col}_{cl1}", width=800,
                                       template="<span style='min-width: 800px'><%= value %></span>")))

However this seems to have no effect.


Set the width of the DataTable instance, it’s set to 600 by default. Also look into the sizing_mode attribute.

Regarding making the table take as much space as possible - I don’t think it’s possible or at least feasible. Bokeh uses SlickGrid for its table widget, and I couldn’t find any way to make it an unconstrained table.

Ah so there’s no way to set the DataTable width to be ‘the minimum required to fit all the columns/rows’/

Exactly. You can compute it yourself somehow and set it. Can’t help with that though.

Gotcha, thanks for the info!