PablocFonseca / streamlit-aggrid

Implementation of Ag-Grid component for Streamlit
https://pypi.org/project/streamlit-aggrid/
MIT License
991 stars 191 forks source link

reload_data=True doesn't work #234

Open sfc-gh-pkommini opened 10 months ago

sfc-gh-pkommini commented 10 months ago

I'm using version 0.3.4.post2. This is my code:

def draw_table() -> None:
    df_filtered = prepare_data_for_table(st.session_state.df)

    options = GridOptionsBuilder.from_dataframe(
        df_filtered,
        enableRowGroup=True,
        enableValue=True,
        enablePivot=True,
    )
    options.configure_pagination(
        paginationAutoPageSize=False,
        paginationPageSize=50,
    )
    options.configure_grid_options(sideBar={"toolPanels": ['filters']})
    options.configure_selection(
        selection_mode='multiple',
        use_checkbox=True,
        header_checkbox=True,
        pre_selected_rows=st.session_state.pre_selected_rows,
    )
    grid_return = AgGrid(
        df_filtered,
        columns_auto_size_mode='autoSizeAllColumns',
        data_return_mode=DataReturnMode.FILTERED,
        enable_enterprise_modules=False,
        gridOptions=options.build(),
        update_mode=GridUpdateMode.MODEL_CHANGED,
        theme='alpine',
        reload_data=True,
        key='my_data',
        enable_quicksearch=True,
    )
    st.session_state.pre_selected_rows = grid_return['selected_rows']

In the method prepare_data_for_table, The selection logic works and gets returned perfectly from the AgGrid(...) call. I select some rows and then have submit button to send the selected rows to our backend. I need to visually mark the items that were sent to the backend.

However the reload_data=True parameter doesn't seem to work and the new data doesn't seem to reflect in the grid. Anyone else experiencing this? How do I get the updated data frame to be rendered?

Also, 0.3.4.post3 doesn't work either. The selection gets lost on refresh in this version and I had to downgrade to 0.3.4.post2.

sfc-gh-pkommini commented 10 months ago

@PablocFonseca Are you still working on this package? Do you have any sense of what parameter(s) need(s) to change? I can make the PR and send it for your approval if you give me a general idea.

PablocFonseca commented 3 months ago

I just got back to st_aggrid development. I'm working on state management and my idea is to deprecate reload_data. The grid will be full responsive to gridOptions and data changes.