Reputation: 11
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()?
Upvotes: 1
Views: 624
Reputation: 17877
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')
Upvotes: 1