Skip to content
Discussion options

You must be logged in to vote

Sure. If you don't need a global reference, you can simply pass the current instance to the change handler:

def change(key, table):
    table.rows = {
        'a': [{'name': 'Aa', 'artist': 'Artist A'}, {'name': 'Ab', 'artist': 'Artist A'}],
        'b': [{'name': 'Ba', 'artist': 'Artist B'}, {'name': 'Bb', 'artist': 'Artist B'}],
        'c': [{'name': 'Ca', 'artist': 'Artist C'}, {'name': 'Cb', 'artist': 'Artist C'}]
    }[key]

@ui.page('/')
def index():
    table = ui.table(columns=[
        {'name': 'name', 'label': 'song_name', 'field': 'name', 'align': 'center'},
        {'name': 'artist', 'label': 'song_artist', 'field': 'artist', 'align': 'center'}
    ], rows=[{'name': None, 'ar…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@SHDocter
Comment options

@falkoschindler
Comment options

Answer selected by SHDocter
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