Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event registration doesn't work in ui.tabs #38

Open
pirx3 opened this issue Feb 20, 2025 · 0 comments
Open

Event registration doesn't work in ui.tabs #38

pirx3 opened this issue Feb 20, 2025 · 0 comments

Comments

@pirx3
Copy link

pirx3 commented Feb 20, 2025

It seems that only the table events in the initialy visible tab are triggered:

from nicegui import ui
from nicegui_tabulator import tabulator

tabledata = [
    {
        "id": 1,
        "name": "Oli Bob",
        "age": "12",
    },
    {
        "id": 2,
        "name": "Mary May",
        "age": "1",
    },
    {
        "id": 3,
        "name": "Christine Lobowski",
        "age": "42",
    },
]

table_config = {
    "height": 205,
    "data": tabledata,
    "layout": "fitColumns",
    "rowHeader": {
        "formatter": "rowSelection",
        "titleFormatter": "rowSelection",
    },
    "columns": [
        {
            "title": "Name",
            "field": "name",
        },
        {
            "title": "Age",
            "field": "age",
        },
    ],
}
with ui.tabs().classes("w-full") as tabs:
    tab1 = ui.tab("Tab1")
    tab2 = ui.tab("Tab2")
    tab3 = ui.tab("Tab3")

with ui.tab_panels(tabs, value=tab1, keep_alive=True).classes("w-4/5 h-full"):
    with ui.tab_panel(tab1).classes("w-full h-full"):
        table1 = tabulator(table_config).on_event(
            "rowClick",
            lambda e: ui.notify(f"Row clicked: {e}"),
        )
    with ui.tab_panel(tab2).classes("w-full h-full"):
        table2 = tabulator(table_config).on_event(
            "rowClick",
            lambda e: ui.notify(f"Row clicked: {e}"),
        )
    with ui.tab_panel(tab3).classes("w-full h-full"):
        table3 = tabulator(table_config).on_event(
            "rowClick",
            lambda e: ui.notify(f"Row clicked: {e}"),
        )

ui.run()
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

No branches or pull requests

1 participant