How to Create a Table with Links Passing Parameters and Dropdowns

Debugging Information:

  1. Running Environment: The app is running locally.
  2. Hosting Platform: N/A (app is not deployed yet).
  3. GitHub Repository: :none
  4. Error Message: There is no error message displayed
  5. Versions:

Hello everyone,

I have an app containing a simple dataframe displaying conversation message. I need some help with creating a table to display data. The table should have the following features:

Link Column: One column(Link) needs to contain links. When these links are clicked, they should pass two parameters, session_id and chat_count, to another page in the same streamlit app.

Dropdown Column: Another column(Publish) should have a dropdown menu, allowing users to select either “Yes” or “No”. In the database, the value of publish is 1 (publish) or 0 (non-publish), but on the front end, it needs to be displayed as Yes or No.

I have tried various methods but haven’t been successful so far. Could someone guide me on how to achieve this?

Thank you in advance!

I have implemented the following code using other methods, but the result is very unattractive. Therefore, I would like to achieve the solution mentioned above, where the link is placed in the corresponding “link” column.:

st.title('1History Conversation')
user_info = st.session_state.user_info
user_id = user_info['user_id']
role = user_info['role']


chat_history_data = fetch_chat_history_data(user_id, role)
# the dataframe doesn't has the param of session_id and chat_count
chat_history_data_df = pd.DataFrame(chat_history_data,
                                    columns=["number", "publish"])

col1, col2 = st.columns([5, 1])

with col1:

    # Display the data in Streamlit
    st.data_editor(
        chat_history_data_df,
        column_config={
            "number": st.column_config.NumberColumn(
                "The number of chat session",
                help="The number of chats",
                width="small"
            ),
            "publish": st.column_config.TextColumn(
                "Publish",
                help="The name of the user",
                width="medium"
            ),
    )

with col2:
    # when click the button, jump to another page to get the detail message
    for index, row in chat_history_data_df.iterrows():
        session_id = row["session_id"]
        chat_count = row["chat_count"]
        if st.button(f"Click me to jump into chat session: {chat_count}", key=f'{chat_count}_{session_id}'):
            st.session_state.session_id = session_id
            st.session_state.chat_count = chat_count
            st.switch_page("pages/2History Detail Conversation.py")