Skip to content
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

Add st.radio in st.column_config #7134

Closed
2 tasks done
ArthLeu opened this issue Aug 8, 2023 · 12 comments · Fixed by #8411
Closed
2 tasks done

Add st.radio in st.column_config #7134

ArthLeu opened this issue Aug 8, 2023 · 12 comments · Fixed by #8411
Labels
feature:st.column_config Related to column config functionalities feature:st.radio type:enhancement Requests for feature enhancements or new features

Comments

@ArthLeu
Copy link

ArthLeu commented Aug 8, 2023

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

Similar to having st.column_config.CheckboxColumn, I wonder if we can have the "single-select" st.radio in the column configuration.

Should not need a major rework.

Why?

Allow the option to select only one row at a time. This is helpful for us to develop a pseudo file explorer with st.data_editor.

How?

Add e.g. st.column_config.RadioColumn

Additional Context

st.radio manual. Why is this called "radio" btw?

@ArthLeu ArthLeu added the type:enhancement Requests for feature enhancements or new features label Aug 8, 2023
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

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.

@jrieke jrieke added the feature:st.column_config Related to column config functionalities label Aug 8, 2023
@jrieke
Copy link
Collaborator

jrieke commented Aug 8, 2023

SelectboxColumn is probably what you're looking for, see the docs here.

We don't plan to add radio buttons to data editor right now since a) the use case should already be covered by SelectboxColumn, b) radio buttons inside a table cell would look a bit weird I think, and c) it would require a significant amount of work since the underlying library does not support it. Will leave this issue open though to see if we get more upvotes.

Why is this called "radio" btw?

That's the standard term for this component in UI design. I actually had no idea why it's called radio though! Turns out, it's because they are named after actual radio receiver buttons:

Radio buttons were named after the physical buttons used on older radios to select preset stations[2][1] – when one of the buttons was pressed, other buttons would pop out, leaving the pressed button the only button in the "pushed in" position.

https://en.wikipedia.org/wiki/Radio_button

@LukasMasuch
Copy link
Collaborator

@ArthLeu Is your suggestion about adding a radio widget within every individual cell, or is it about allowing the user to only select a single row (which would be a bit related to #688)?

@ArthLeu
Copy link
Author

ArthLeu commented Aug 8, 2023

@ArthLeu Is your suggestion about adding a radio widget within every individual cell, or is it about allowing the user to only select a single row (which would be a bit related to #688)?

Sorry. To clarify, select one row at a time and return the row index. I know this is mentioned in #688 and addressed with Selectbox column. But with Selectbox it allows multiple selections.

What if we just want a single row to be selected at a time? It would be pretty time consuming for users to deselect the others manually.

And to deselect, we can't set False to a data_editor column either. I tested this with v1.25.0. User actions do triggers Streamlit rerun, but cell values don't get changed with e.g. df["Select"] = False.

So that's why I thought the radio column is still needed.

@CHerSun
Copy link

CHerSun commented Aug 25, 2023

@ArthLeu Is your suggestion about adding a radio widget within every individual cell, or is it about allowing the user to only select a single row (which would be a bit related to #688)?

Sorry. To clarify, select one row at a time and return the row index. I know this is mentioned in #688 and addressed with Selectbox column. But with Selectbox it allows multiple selections.

What if we just want a single row to be selected at a time? It would be pretty time consuming for users to deselect the others manually.

And to deselect, we can't set False to a data_editor column either. I tested this with v1.25.0. User actions do triggers Streamlit rerun, but cell values don't get changed with e.g. df["Select"] = False.

So that's why I thought the radio column is still needed.

a long needed option to be able to select single row and get feedback on that to allow easier items selection for further processing and displaying info. Radio column where only single row can be selected might be a good way for st.data_editor, but what about st.dataframe?

@cebasfu93
Copy link

🤚🏼

@nickgreengithub
Copy link

nickgreengithub commented Nov 18, 2023

This is definitely needed - I'm working on a supply chain app and various times wished for either this, or the ability to select a table row to prompt an action.
For example, selecting from item records with various details, to perform an action against one of them or populate a form view or chart in a another column, relating to one of those records...
It's standard in old school java and microsoft applications and is definitely going to be handy

@afza1
Copy link

afza1 commented Dec 12, 2023

Defneed single select option instead of checkboxcolumn.
the user experience is really friendly if the use case is to select one row at a time. as-is, user has to unselect and than select again.
it would be so much easier to develop the use case and improve the UX as well.

@xinyis
Copy link

xinyis commented Mar 13, 2024

+1 to the single selection feature of data-editor. It is needed for our use case too.

@jrieke
Copy link
Collaborator

jrieke commented Apr 19, 2024

Ah sorry, I completely misunderstood this feature request in the beginning! If it's about selecting a single row from a dataframe, the good news is that this will be covered by the upcoming dataframe selections feature we're working on (#8411). See my update with link to demo app here (and I'll also give further updates on that other issue since it's the more general one).

@LukasMasuch
Copy link
Collaborator

LukasMasuch commented May 13, 2024

We will release row & column selections for st.dataframe in the 1.35 release. Single-row selection can be activated like this:

selection = st.dataframe(df, on_select="rerun", selection_mode="single-row")

This will probably enable many use cases related to the radio column. It's unlikely that we will add a dedicated radio column to the column config in the near future. What's more likely is that we add the same selection support to st.data_editor as well.

@CHerSun
Copy link

CHerSun commented May 13, 2024

We will release row & column selections for st.dataframe in the 1.35 release. Single-row selection can be activated like this:

selection = st.dataframe(df, on_select="rerun", selection_mode="single-row")

Thank you!!! I don't know about others, but row selection is really one of the most wanted features for me.

LukasMasuch added a commit that referenced this issue May 13, 2024
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.column_config Related to column config functionalities feature:st.radio type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants