How to refresh ag-grid data after deleting selected row

Dears,

I use MongoDB to store data, but I facing one issue that the ag-grid did not refresh after click customize button to delete selected row.

please advise how to achieve this goal, thanks!

I have the same issue, but it works (in terms of deleting the row) when I check the select box for that row a second time. I’ve never been able to figure out a solution, but haven’t looked into it too hard as it’s kind of functional. I think it’s because the aggrid component doesn’t refresh after the first deletion.

Hi @ac3

thank you for your comment.

You need to use the grid builder. It will be something like this:

1) Import gridoptionsbuilder

from st_aggrid import AgGrid, GridOptionsBuilder

2) Make object (and apply the settings you like)

gb = GridOptionsBuilder.from_dataframe(loaded_data)
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=True)
gb.configure_selection('multiple', use_checkbox=False, groupSelectsChildren=True, groupSelectsFiltered=True)
gb.configure_pagination(enabled=True)
my_gridOptions = gb.build()

3) Apply to Aggrid

new_dataframe = AgGrid(loaded_data, 
                       gridOptions = my_gridOptions,
                      update_mode=GridUpdateMode.MODEL_CHANGED
)

See the link for all details

Hi, @lee0423! I’ve just had the same issue and what I did was inserting an empty button (that doesn’t explicitly trigger any event) that, when clicked, updates the table without having to double click or unselect the row. I know it might not be the most efficient solution, but (in my opinion) was the best I found in terms of user experience and interface. The code should be something like:

col1, col2= st.columns(2)
remove_row_button = col1.button("Remove Selected Row")
refresh_button = col2.button("Refresh Grid")

Hope this helps!

@matheusmafraoandrade can you please provide the code full code i.e the code which removes the selected row from grid. please. I have tried multiple ways but was unable to achieve it. even tried in github : python - streamlit AgGrid deleting row doesnt refresh data in the backend - Stack Overflow

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