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

Consider adding a method to get the selected row records #28

Closed
CrystalWindSnake opened this issue Oct 21, 2024 · 0 comments · Fixed by #30
Closed

Consider adding a method to get the selected row records #28

CrystalWindSnake opened this issue Oct 21, 2024 · 0 comments · Fixed by #30
Labels
enhancement New feature or request

Comments

@CrystalWindSnake
Copy link
Owner

In the Tabulator documentation, multiple methods exist to get the records of selected rows in a table, but the getSelectedRows method does not work correctly; instead, getSelectedData should be used.

from nicegui_tabulator import tabulator
from nicegui import ui

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,
    "rowHeader": {
        "formatter": "rowSelection",
        "titleFormatter": "rowSelection",
    },
    "columns": [
        {"title": "Name", "field": "name", },
        {"title": "Age", "field": "age",},
    ],
}


@ui.page("/")
def page():
    table = tabulator(table_config)

    async def get_data():
        rows = await table.run_table_method("getSelectedData")
        ui.notify(rows)

    ui.button("Get Selected data", on_click=get_rows)

Consider adding the method get_selected_data to get the selected row records

@ui.page("/")
def page():
    table = tabulator(table_config)

    async def get_rows():
        rows = await table.get_selected_data()
        ui.notify(rows)

    ui.button("Get Selected Rows", on_click=get_rows)
@CrystalWindSnake CrystalWindSnake added the enhancement New feature or request label Oct 21, 2024
@CrystalWindSnake CrystalWindSnake linked a pull request Oct 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant