-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Coming soon] Allow dataframe rows to be selectable and trigger a function in Python code #688
Comments
Hi @timforr -- Thanks for the feature request! This seems like a natural progression for Streamlit, pending some conversation within the team of course. |
Do we have an update on this? |
Yes this functionality would be very extremely useful! I would be keen to know if there is an update . Thanks! |
I have found myself multiple times over the past year needing this -- I am surprised it is still not implemented! Something as easy as |
Is there any workaround until this enhancement is completed? |
Any update on this? It would be really useful to be able to click on a specific cell/row and have that trigger an event in Python to update the page. |
I need this too. Just a simple (Checkboxes on each row would also be an alternative, though in my case I don't need multiselect) |
This would unlock a lot of interesting use cases. Typically data is presented in a table. Being able to click would enable pivoting views which is common operation on data. |
Hi all, any update on this? |
We're working on this at the moment. No concrete launch data but we should have something during the next few months! |
Might be able to use newly added feature to cover this issue. |
How does editing cells in the table allow to react to a clic or to know which row has been selected? These are different use cases. |
Yes, true. Based on examples in https://docs.streamlit.io/library/advanced-features/dataframes?ref=streamlit it seems possible using the session state (though maybe not yet straight forward). If not, the Next Up section in the original link states a more straight forward way to do this should be here soon:
|
Hi, |
We just finished a very rough prototype for dataframe selections: https://dataframe-row-selections.streamlit.app/ Feel free to give it a try but note that it's still under active development, so things might and will change! Let me know if you have any feedback. For a broader picture on selection events, see my comment here. |
Quick update: we're quite advanced on the prototype I posted above, as well as on the API discussions. We're currently planning to release dataframe selections for both rows + columns sometime in |
## Describe your changes This PR adds row and column selection support to `st.dataframe`. It can be used like this: ```python selection = st.dataframe( df, on_select="rerun", selection_mode="single-row" ) ``` - [Demo App](https://dataframe-row-selections.streamlit.app/) https://github.com/streamlit/streamlit/assets/2852129/f3ff476a-0bd0-4b82-bc97-6bda3a3be98c ## GitHub Issue Link (if applicable) - Closes #688 - Closes #7134 - #455 - #8319 ## Testing Plan - Added unit tests - Added e2e tests (see #8634) ```[tasklist] ### e2e tests - [x] Single row/column selection - [x] Multi row/column selection - [x] Mixed selections - [x] Screenshot of a dataframe with multiple selections - [x] Clear selections via toolbar - [x] Clear selections via escape - [x] Select all rows in multi-row selection via top checkbox - [x] Optional: Test drag and drop selection - [x] Optional: Test shift selections - [x] Optional: Test selections in form - [x] Have some test cases work with session state and others with return value - [x] Add a test case validating that the callback gets called ``` --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Benjamin Räthlein <benjamin.raethlein@gmail.com>
We will release row & column selections for selection = st.dataframe(df, on_select="rerun", selection_mode="single-row") Or for multi-row & column selections: selection = st.dataframe(df, on_select="rerun", selection_mode=("multi-row", "multi-column")) You can try it out in this demo. |
@LukasMasuch - thanks for the demo, this will be great for our application! |
Thank you soo much for this update. @LukasMasuch can you let us know when streamlit is planning to release version 1.35? It will be very helpful. |
@rutuja1409 Probably today or tomorrow :) |
Hey, thank you so much @LukasMasuch for this nice addition!! 👏 Small question: is there a way to pre-select a row before the dataframe is initially rendered? In my usecase, a specific query parameter can be provided in order to pre select a row when accessing the page. This was possible with streamlit Aggrid (example here). I was wondering if there was a trick to do the same with |
@pierreb-met this is not yet possible, but it would be a reasonable change 👍 It would be awesome if you could create a feature request for this. |
Hey @LukasMasuch Thank you for the new version. I tried it, and have a question. So its working fine when I select a row and it displays at the bottom. But consider I have an selectbox prior, and then based on the value the data is displayed, however the index gets reset from 0 while displaying the rows selected. Here you can see the index is 2, but the on-select functionality start the index from 0 on filtered dataframe. |
@rutuja1409 The returned list in |
@LukasMasuch I'm working on integrating this change. One issue is that this selectable checkbox column has no header/label, so it's not obvious to users that cells in that column can be selected. Is there any way to add a column label for this? |
@pkonduri there isn't a way yet to set a header label for the selection column :( |
@LukasMasuch thanks for the response. Would be great if this small change could be added as a quick follow up to this task. Especially for public facing apps, users may not realize that the column is meant to be selectable, unless they accidentally hover over the cells. |
@LukasMasuch while both solutions (adding the option for a column header, and outlining the checkboxes as suggested in #8941 ) help achieve clarity that the cells are selectable, there are subtle reasons why one may choose one option over the other.
I think supporting both options makes sense. But at the very least, offering the ability to add a label to the checkbox column sounds more intuitive to me. This way, this column is not treated any differently than other columns. Ideally it will mimic the functionality we find in st.column_config.CheckboxColumn for st.data_editor |
I have a problem with linking on_select to an ID that is in the database |
The IDs are the positional indices and are expected to always map to the row position in the input dataset.
Do you mean sorting on the frontend / UI or sorting the dataframe on the backend? |
I have a problem with data_editor and column_config |
The positional index with |
Thanks you! |
Problem
I have a st.table displaying search results. I want to be able to click on a specific row (or select several rows) and have that trigger an event in Python to update the page.
Solution
MVP: Table rows are clickable and trigger a custom event
Possible additions: What are other things that could be added to the MVP over time to make it better?
Preferred solution: More fully-featured solution similar to DTTables where we can specify custom table styling, embed objects like images in to table cells, select multiple rows or cells, etc.
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
The text was updated successfully, but these errors were encountered: