PablocFonseca / streamlit-aggrid

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

Aggrid rendering bug with st.tab #219

Closed FateScript closed 1 year ago

FateScript commented 1 year ago

I'm using:

python3.10.9
streamlit               1.21.0
streamlit-aggrid        0.3.4.post3

Here is my code to reproduce the bug, After streamlit run the code, the Aggrid table in tab2 is not rendered in the right way. BTW, using fit_columns_on_grid_load=True also not works for me.

import pandas as pd
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder, ColumnsAutoSizeMode

def aggrid_interactive_table(key: str = None):
    df = pd.DataFrame({
        'num_legs': [2, 4, 8, 0],
        'num_wings': [2, 0, 0, 0],
        'num_specimen_seen': [10, 2, 1, 8]
    }, index=['falcon', 'dog', 'spider', 'fish'])

    options = GridOptionsBuilder.from_dataframe(df, enableRowGroup=True, enableValue=True, enablePivot=True)
    options.configure_side_bar()
    options.configure_selection("single")

    grid = AgGrid(
        df,
        columns_auto_size_mode=ColumnsAutoSizeMode.FIT_ALL_COLUMNS_TO_VIEW,
        gridOptions=options.build(),
        reload_data=True,
        key=key,
    )
    return grid

if __name__ == "__main__":
    tab1, tab2 = st.tabs(["tab1", "tab2"])
    with tab1:
        grid = aggrid_interactive_table(key="tab1")
    with tab2:
        grid2 = aggrid_interactive_table(key="tab2")
FateScript commented 1 year ago

Any update? @PablocFonseca

broccoliboy commented 1 year ago

Perhaps a duplicate of #159?

FateScript commented 1 year ago

@broccoliboy #159 Didn't solve my issue. Anyway, I work around this issue by using streamlit_option_menu instead of st.tab and it works well.