Aggrid Selectbox issue in streamlit

Summary

Share a clear and concise description of the issue. Aim for 2-3 sentences.
Im using Aggrid in which there is one table called plant and there is a select row option, im using an edit button between this to edit the plant table in which the same plant table is displayed and in that if i select a row the table is disappearing.

Attached the snippet for reference

Steps to reproduce

Code snippet:

add code here
```st.set_page_config(page_title="ADMIN",layout="wide")

hide_streamlit_style = """
            <style>
            #MainMenu {visibility: hidden;}
            footer {visibility: hidden;}
            </style>
            """
st.markdown(hide_streamlit_style, unsafe_allow_html=True) 

custom_css = {
    ".ag-header-cell-text": {"font-size": "large","color":"black","--ag-font-size": "15px"},".ag-theme-material": {"--ag-font-size": "15px"}
    }
conn = psycopg2.connect(
    host="localhost",
    database="oee_database",
    user="postgres",
    port='5432',
    password="security@123"
    )

cur = conn.cursor()

selectect = option_menu(menu_title='', options=[
                        "Plant", "Machine"], orientation="horizontal")

if selectect == "Plant":
    
    st.header("Plant Details")

    dfP = plant_data()
    dfP = dfP[['Plant Name','Shop Name','Plant Address','Electricity_tariff']]
    dfP = dfP.sort_values(by='Shop Name', ascending=True)
    gd = GridOptionsBuilder.from_dataframe(dfP)
    gd.configure_selection(selection_mode='multiple',use_checkbox=True)
    grid_options = gd.build()
    
   
    grid_table_P   = AgGrid(dfP,height=400,fit_columns_on_grid_load=True,gridOptions=grid_options,custom_css=custom_css,
                        allow_unsafe_jscode=True,
                        update_mode=GridUpdateMode.SELECTION_CHANGED, theme="material", key='pd')
    selected_row_P = grid_table_P["selected_rows"]

    if st.button('Edit'):
        funct = st.selectbox(label="Select the changes", options=['Update Plant Details', 'Delete Plant Details', 'Single Plant Details Insertion', 'Multiple Plant Details Insertion'], key='77')
        dfP = plant_data()
        dfP = dfP[['Plant Name','Shop Name','Plant Address','Electricity_tariff']]
        dfP = dfP.sort_values(by='Shop Name', ascending=True)
        gd = GridOptionsBuilder.from_dataframe(dfP)
        gd.configure_selection(selection_mode='multiple',use_checkbox=True)
        grid_options = gd.build()
        

        grid_table_P   = AgGrid(dfP,height=400,fit_columns_on_grid_load=True,gridOptions=grid_options,custom_css=custom_css,
                            allow_unsafe_jscode=True,
                            update_mode=GridUpdateMode.SELECTION_CHANGED, theme="material", key='pdu')
        selected_row_PU = grid_table_P["selected_rows"]
        if selected_row_PU:
            st.write("Update")


   
    if selected_row_P:
        
        dfn  = pd.DataFrame(selected_row_P)
        dfn  = dfn.drop(columns=['_selectedRowNodeInfo'])
        sn= str(dfn["Shop Name"][0])
        st.header("Shift Details")
        dfs=shift_data(sn)
        dfs=dfs[['Shop Name','Shift Type','Shift From','Shift To']]
        dfs = dfs.sort_values(by='Shop Name', ascending=True)
        
        gd = GridOptionsBuilder.from_dataframe(dfs)
        gd.configure_selection(selection_mode='multiple',use_checkbox=True)
        grid_options = gd.build()
    
        
        grid_table = AgGrid(dfs,height=400,fit_columns_on_grid_load=True,gridOptions=grid_options,custom_css=custom_css,
                        allow_unsafe_jscode=True,
                            update_mode=GridUpdateMode.SELECTION_CHANGED, theme="material", key='bbb1')
        selected_row_S = grid_table["selected_rows"]


If applicable, please provide the steps we should take to reproduce the error or specified behavior.

**Expected behavior:**

Explain what you expect to happen when you run the code above.

**Actual behavior:**

Explain the undesired behavior or error you see when you run the code above.
If you're seeing an error message, share the full contents of the error message here.

### Debug info

- Streamlit version: Streamlit, version 1.21.0
- Python version: python 3.9.6
- Using python environment
- OS version: windows 10
- Browser version:

### Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out [this doc](https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/app-dependencies) and add a requirements file to your app.

### Links

* Link to your GitHub repo:
* Link to your deployed app:

### Additional information

If needed, add any other context about the problem here.

Hi @AnandaKrishnan_Gopal,

Please update your post to include a code snippet that we can run as-is (the code snippet you shared doesn’t include import statements and plant_data() is undefined). This will help us get you an answer as quickly as possible :smiley: