How to improve Aggrid speed?

Hey everyone!

I’m currently using Ag-grid in my application. Every time you select a row or enter in an input, Ag-grid sends back data to Streamlit. This really eats away at the performance of the app.

Right now the user needs to select a row and in the Code column select A, B, C. Seems like it take 3-4 seconds for Ag-grid to process the selection and Code input.

I did try changing the update_mode=GridUpdateMode.SELECTION_CHANGED to .Manual, but I don’t like the save button you have to press. This is an extra step I don’t want to have.

After the user is done making their entries I have them click a button that saves the entries. Is there a way I can tie my button to work with the Ag-grid save button that appears when you set Update Mode to .Manual? So you only have to press one button?

Any other ideas to improve performance?

Thank you in advance.

dropdownlst = ('A','B', 'C')
gd = GridOptionsBuilder.from_dataframe(df)
gd.configure_pagination(enabled=True)
gd.configure_default_column(editable=True, groupable=True)
gd.configure_column('Code', editable=True, cellEditor='agSelectCellEditor', cellEditorParams={'values': dropdownlst })
gd.configure_selection(selection_mode = 'multiple',use_checkbox=True)
gridoptions = gd.build()
grid_table = AgGrid(df, columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS, gridOptions=gridoptions,
                    update_mode=GridUpdateMode.SELECTION_CHANGED | GridUpdateMode.VALUE_CHANGED,
                    height=500, width = 7000,
                    allow_unsafe_jscode=True,
                    enable_enterprise_modules = False,
                    )

sel_row = grid_table["selected_rows"]


df_selected = pd.DataFrame(sel_row)

if st.button('Update Code', key=1):
        *saves user inputs*
1 Like

Hey! I use your script but I didn’t find the button from the Manual. I actually want to have the manual save button. Do you know how to get it back?

update_mode=GridUpdateMode.SELECTION_CHANGED

I think you ser the above code’s update mode to “MANUAL”

AgGrid — streamlit-aggrid 0.2.3 documentation

image

Yes this is what I did but didn’t work, here’s a snippet. Can I ask what version of streamlit and aggrid are you using?

                        gd = GridOptionsBuilder.from_dataframe(pd.DataFrame([{'name':'a','age':12},{'name':'a','age':20}]))
                        gd.configure_pagination(enabled=True)
                        gd.configure_default_column(editable=True, groupable=True)
                        gd.configure_column('Code', editable=True)
                        gd.configure_selection(selection_mode = 'multiple',use_checkbox=True)
                        gridoptions = gd.build()
                        grid_table = AgGrid(pd.DataFrame([{'name':'a','age':12},{'name':'a','age':20}]), gridOptions=gridoptions,
                                            update_mode = GridUpdateMode.MANUAL,
                                            height=500, width = 7000,
                                            allow_unsafe_jscode=True,
                                            enable_enterprise_modules = False,
                                            )

                        sel_row = grid_table["selected_rows"]
                        df_selected = pd.DataFrame(sel_row)

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