Cannot filter the ui.table content by set_filter() on the values of a specific column only #5140
v116mo
started this conversation in
Ideas / Feature Requests
Replies: 1 comment 1 reply
-
Hi @v116mo, Actually I do not know how to do it from inside the table element. I read that there are few plugins who can do this but that's beyond my skill levels 😄 But I suppose you could always filter the df directly and refresh the table, if that's acceptable in your workflow. import pandas as pd
from nicegui import ui
filter_container = ui.row()
data = {
'id': [1,2,3,4,5,6,7],
'name': ['A Failed', 'B OK', 'C', 'OK', 'E', 'F', 'G'],
'status': ['OK', 'Failed', 'OK', 'Failed', 'OK', 'Failed', 'Failed']
}
df = pd.DataFrame(data)
filter = list(set(data['status']))
with filter_container:
ui.toggle(filter, on_change=lambda e: update_table(e))
with ui.row() as container:
ui.table.from_pandas(df)
def update_table(e):
container.clear()
filtered_df = df[df['status'] == e.value]
with container:
ui.table.from_pandas(filtered_df)
ui.run() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I try to shown the ui.table filtered by the values of a specific dataframe column, it turns out the values of other columns will be taken into account like a full text search. How can I limit the filter to a specific column only?
Below is the code to show the filtering with undesired outcome.
Beta Was this translation helpful? Give feedback.
All reactions