Using Streamlit , how can we open new page while selecting any table in st_aggrid view

Like we show our table using st_aggrid view in which while selecting any row in table point me to new page and on that page we can see the value of selected row and do some operation

Hi @Aakash_Kumar,

Are you looking for something like this?

import pandas as pd
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder
from st_aggrid.shared import GridUpdateMode

if "dta" not in st.session_state:
    st.session_state.dta = None

df=pd.DataFrame({ "Name": ['Paul', 'Gina'], "Age": [43, 35], "Inducted": [True, False], 
                  "Firm": ['Google', 'Microsoft'], "JDesc": ['Analyst', 'Programmer']})
gridOptions = GridOptionsBuilder.from_dataframe(df)
gridOptions.configure_selection('single', use_checkbox=True)
gb =

def sub_page():
    st.subheader("Sub Page")
    st.write(f'Name: {st.session_state.dta["selected_rows"][0]["Name"]}')
    st.write(f'Firm: {st.session_state.dta["selected_rows"][0]["Firm"]}')

    if st.button("Return to Main Page"):
        st.session_state.runpage = main_page

def main_page():
    st.subheader("Main Page")
    st.session_state.dta = AgGrid(df, gridOptions=gb, height=150, update_mode=GridUpdateMode.SELECTION_CHANGED)

    if len(st.session_state.dta["selected_rows"]) == 1:
        st.session_state.runpage = sub_page

if 'runpage' not in st.session_state:
    st.session_state.runpage = main_page


1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.