Streamlit-aggrid -> browser refreshing issue

Im running my app locally and have installed streamlit-aggrid, I attempted to use a sample code, but I’m encountering an odd behavior. when i refreshes the browser the table display is getting lost sometimes

import pandas as pd
import streamlit as st
from st_aggrid import AgGrid

df = pd.read_csv(
    "https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv"
)

AgGrid(df)

each time I refresh the browser, my terminal prints True even though I haven’t included any print statement in my code.

You need to put the dataframe in a cache or memory for performance.

@st.cache_data(ttl='1d')  # clear the cache after 1 day
def data():
    df = pd.read_csv(
        "https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv"
    )
    return df

Then use that in aggrid.

df = data()

AgGrid(
    df,
    enable_enterprise_modules=False,
    height=300
)

Happy to see this great library has been updated.

This was part of the debugging that was left and should not cause an issue.

1 Like

Hi @ferdy thank you for the response now its working fine and also I have upgraded streamlit for resolving the issue, now i have another concern:


so, I have this filter dropdown in order to close it either I need to click on the filter icon or anywhere inside that grid but when I clicked outside of the grid, it will not close is there any solution for it.

It could be just a design decision not to exit when user is wandering outside of the grid. It is also a reasonable decision because the user can come back to it later to finish what needs to be done in the grid. Also if there is a mouse-slip outside of the grid, no worries the user can comeback to it too.

1 Like

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