Skip to content

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

@pirx3

Description

@pirx3

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions