Skip to content

Conversation

@maximlt
Copy link
Member

@maximlt maximlt commented Nov 27, 2025

This PR allows row_content to be an awaitable. When it is an awaitable, we display first a small spacer with a loading spinner, replaced by the content returned by the function.

Micro app to play around with this feature:

import asyncio

import panel as pn
import pandas as pd

df = pd.DataFrame({"value": [0, 1, 2]})

async def async_row_content_cb(event):
    await asyncio.sleep(1)
    print("Event", event)
    return str(event)

def row_content_cb(event):
    print("Event", event)
    return str(event)

b = pn.widgets.Button(name="expanded")

t = pn.widgets.Tabulator(
    df,
    width=300,
    # row_content=row_content_cb,
    row_content=async_row_content_cb,
    # embed_content=True,
    # expanded=[1],
)

b.on_click(lambda e: setattr(t, 'expanded', [0]))

pn.Row(b, t).servable()

Draft as I'd like to test it in an app with a more complex row_content function.

@maximlt maximlt marked this pull request as draft November 27, 2025 09:28
Comment on lines +1645 to +1646
placeholder.object = resolved
placeholder.loading = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
placeholder.object = resolved
placeholder.loading = False
placeholder.param.update(object=resolved, loading=False)

return child.children[0].text


def test_tabulator_expanded_content_async(document, comm):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you have to make these tests async as well

Suggested change
def test_tabulator_expanded_content_async(document, comm):
async def test_tabulator_expanded_content_async(document, comm):

assert len(model.children) == 1


def test_tabulator_content_embed_async(document, comm):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_tabulator_content_embed_async(document, comm):
async def test_tabulator_content_embed_async(document, comm):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants