Skip to content

How to set the browsing page of the table? #3228

Answered by falkoschindler
logandoo asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can keep track of the current pagination state and use it to re-create the table:

rows = [
    {'name': f'item {i + 1}', 'state': False} for i in range(6)
]
columns = [
    {'name': 'name', 'label': 'name', 'field': 'name'},
    {'name': 'state', 'label': 'state', 'field': 'state'}
]
pagination = {'rows_per_page': 5}

def handle_state_change(e: events.GenericEventArguments) -> None:
    for row in rows:
        if row['name'] == e.args['row']['name']:
            row['state'] = e.args['row']['state']
    show_table.refresh()

@ui.refreshable
def show_table() -> None:
    table = ui.table(columns=columns, rows=rows, pagination=pagination)
    table.add_slot('body-cell-state', '''

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@logandoo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by logandoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants