Selecting a row forces AgGrid to reload

Hi everyone,
When I select a row in AgGrid it forces the entire table to be re-run. This is due to: update_mode=GridUpdateMode.SELECTION_CHANGED. I can resolve this with update_mode=GridUpdateMode.VALUE_CHANGED, but then no data is being recorded for the selected row and I cannot pass it to the next function im my app. Is there any way to resolve this withiut having to reload the entire table each time I select a row? Thanks for help and fresh ideas!
I am using this funciton to call AgGrid in my app:

def AgGrid_with_display_rules(df):
    gd = GridOptionsBuilder.from_dataframe(df)
    gd.configure_default_column(editable=False, groupable=True)
    gd.configure_selection(selection_mode='multiple', use_checkbox=True)
    gridoptions =
    grid_table = AgGrid(df, gridOptions=gridoptions,
    sel_row = grid_table["selected_rows"]
    return grid_table, sel_row

Hey @PeterPetersen,

Thanks for sharing this question! Can you add a few more lines to your code snippet so we can run it? :pray:t3:

1 Like

Hi there @PeterPetersen ,

Try setting the key parameter of the AgGrid method. A good trick is to use a session state variable counter, and whenever you want to force AgGrid to refresh programmatically, you increment the counter.

Hope this helps!


Hi Caroline,
Many thanks for getting back in touch.
The data source of my AgGrid is getting downloaded to streamlit from a Google Cloud Storage Bucket. In turns out, that all I had to do was to set @st.cache before my GCS download function. Once the Pandas pickle gets downloaded and is cached the AgGrid component selection works as expected.