Skip to content

How can I get the number of filtered rows in ui.table in real time? #4184

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

You must be logged in to vote

Hi @Xsakura1314,

You can subscribe to value changes of the input element:

async def update_row_count_label():
    count = await table.get_computed_rows_number()
    row_count_label.text = f'{count} rows'

filter_input = ui.input("Search by name/age").bind_value(table, "filter")
filter_input.on_value_change(update_row_count_label)
row_count_label = ui.label()

Because get_computed_rows_number needs to be awaited before passing it to the row_count_label, we need to wrap the call in an async update_row_count_label function.

Replies: 1 comment 1 reply

Comment options

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

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