From c7fecfc60e2a4441cd8a305634cf670ea25ffbfa Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 22 May 2022 21:45:21 +0200 Subject: [PATCH] simplified handling newly added columns --- stand.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stand.py b/stand.py index 3a58a82..3ad18c7 100644 --- a/stand.py +++ b/stand.py @@ -24,10 +24,8 @@ changed = restapi.changed df = restapi.data -columns = st.session_state.get("columns", set()) -new_columns = set(df.columns) -cols_changed = (columns != new_columns) -st.session_state.columns = new_columns +# encode the column names into the key, thus trigger a hard reload (like F5) when the columns change +key = "stand:" + "+".join(str(col) for col in df.columns) @@ -79,7 +77,7 @@ response = AgGrid( fit_columns_on_grid_load=True, reload_data=changed, - key=None if cols_changed else "stand" # None triggers a hard reload like F5, which is needed if new columns were added + key=key )