NiceGUI Table filter options

188 views Asked by At

Please help me with ui table(), bind filter(). How can I create search and find data in the table?

I have tried giving ui input and generating a search string and I am facing some issues while binding the input value? what can i call inside the bind filter()?

1

There are 1 answers

0
Falko On

You can either write

filter_input.bind_value_to(table, 'filter')

or

table.bind_filter_from(filter_input, 'value')

Here is a complete example:

filter_input = ui.input()
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'},
]
ui.table(columns=columns, rows=rows, row_key='name').bind_filter_from(filter_input, 'value')