Pass new or overwrite value to created text_input

Hello everyone.

I have a text_input created with no values and disabled.
After selecting a row in my AgGrid table, I would like that field to receive the new value from the AgGrid table.

grid_table = AgGrid(df_planting, 
                    gridOptions=gridoptions,
                    update_mode=GridUpdateMode.SELECTION_CHANGED,
                    allow_unsafe_jscode=True,
                    height=300,
                    theme=AgGridTheme.BALHAM)
sel_row = grid_table["selected_rows"]
grower_name_input = st.text_input(label="Grower Name", disabled=True, key='teste_in')
        if len(sel_row) == 1:  #selection from aggrid table  
            row_dict = sel_row[0]
            grower_name_input =row_dict.get('grower_id')```

Thank you guys for your support!

Hi @Davi_Soares_Batista,

Thanks for posting!

To clarify, you’re looking to pre-populate the text input widget with the value from a specific cell in your aggrid table?

Caroline :balloon:

1 Like

Hi @Caroline.
You are correct.
Thank you for your answer.

Hi @Isaak_Saba :wave:

Feel free to fork the code below:

It’s a simple demo I created showcasing how users can edit cells in a dataframe via the streamlit-aggrid component.

You can add a step where the desired cell from the selected row is passed as a variable to st. text_input widget.

I hope this helps - let me know how you go.

Best,
Charly

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