Skip to content

AG Grids inside hidden tabs don't get mounted #3033

Open
@falkoschindler

Description

Description

As noticed in #1869 (comment), when creating AG Grids on currently hidden tabs, they don't get mounted and interacting with them can cause problems:

with ui.tabs().classes('w-full') as tabs:
    one = ui.tab('One')
    two = ui.tab('Two')
with ui.tab_panels(tabs, value=one).classes('w-full'):
    with ui.tab_panel(one):
        async def get_data():
            ui.notify(await grid.get_client_data())
        ui.button('Get data', on_click=get_data)
    with ui.tab_panel(two):
        grid = ui.aggrid({
            'columnDefs': [{'headerName': 'Name', 'field': 'name'}],
            'rowData': [{'name': 'Alice'}, {'name': 'Bob'}],
        })

When clicking "Get data" before visiting tab "Two" for the first time, a JavaScript error occurs and we don't see a notification.

How can we make sure every NiceGUI element is created, even if it is hidden on another tab?


Related discussion: #2157

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions