Tabulator does not show formatting when used in Column

I am using styling for displaying a dataframe using Tabulator. The example is from here

Styling shows when I use
styled.show()
to display the page, but no styling is shown when
pn.Column(styled).show() is used. Here is my complete code. I need to use pn.Column so that I can show other content on the page.

import datetime as dt
import pandas as pd
import panel as pn

pn.extension('tabulator')

style_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))

def color_negative_red(val):
    """
    Takes a scalar and returns a string with
    the css property `'color: red'` for negative
    strings, black otherwise.
    """
    color = 'red' if val < 0 else 'black'
    return 'color: %s' % color

def highlight_max(s):
    '''
    highlight the maximum in a Series yellow.
    '''
    is_max = s == s.max()
    return ['background-color: yellow' if v else '' for v in is_max]

styled = pn.widgets.Tabulator(style_df, page_size=5)
styled.style.applymap(color_negative_red).apply(highlight_max)

pn.Column(styled).show()

How do I make my styled Tabulator show style when shown along with other components?

There is a strange behavior
If pn.extension('tabulator') is not used the display is correct
If you use pn.extension(‘tabulator’) reload the page once and the dispaly should be correct

1 Like

@xavArtley Thanks for the tip! I am using pn.extension(‘tabulator’) and refreshing the page displays the style! Still, I’d consider this a bug.

However, this is not a solution for me as I have a pn.state.add_periodic_callback that keeps getting the latest dataframe, and I loose all the styling once the dataframe updates.

1 Like

Hi @sandhya-sago

Could you try reporting this as a bug? Issues · holoviz/panel (github.com)

A minimum reproducible example and screenshots/ gif would make it easy to get started fixing.

Thanks.

Strangely, a week later, I no longer see this problem, so will not be opening a github issue.

1 Like