Skip to content

Table - show and hide columns by dropdown or select #692

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

You must be logged in to vote

@miqsoft Now I finally found the time try it myself. Here is a minimum example I came up with:

columns = [
    {'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
    {'name': 'age', 'label': 'Age', 'field': 'age', 'sortable': True},
]
rows = [
    {'name': 'Alice', 'age': 18},
    {'name': 'Bob', 'age': 21},
    {'name': 'Carol'},
]
visible_columns = {column['name'] for column in columns}
table = ui.table(columns=columns, rows=rows, row_key='name')

def toggle(column: dict, visible: bool) -> None:
    if visible:
        visible_columns.add(column['name'])
    else:
        visible_columns.remove(column['name'])
    table._props['columns'] = [column for c…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

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