streamlit / streamlit

Streamlit — A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
33.44k stars 2.91k forks source link

Preserve row selections when sorting `st.dataframe` on the frontend #8851

Open sfc-gh-dmatthews opened 1 month ago

sfc-gh-dmatthews commented 1 month ago

Checklist

Summary

When using st.dataframe with row selections (and not column selections), sorting the dataframe will clear away the row selections. Users can (partially) get around the issue using the search function in the dataframe toolbar which preserves row selections to make working with larger dataframes feasible.

Why?

Although the search bar provides a workaround when handling large datasets, it's a very natural thing for a user to want to sort a dataframe to get to rows they want to select. Currently, they need to be told (or discover frustratingly) that they can't sort in the middle of making row selections.

How?

Preserve the selection during frontend manipulation.

Additional Context

No response

github-actions[bot] commented 1 month ago

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

nimeshrevo commented 3 weeks ago

Also, is there a way to preserve the selection state, when the table is being updated. For example: I have a st.dataframe with selection_mode = "multi-row" inside a function with experimental_fragment decorator, as I need to update the table on certain interval. As, a user if I select row(s), they get deselected while the table gets updated. Is there any work around for this? Any help is appreciated, Thank you!