From 2dbcc6904b0e78f0e0f3a80043ce6baef5059440 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 22 May 2022 21:25:44 +0200 Subject: [PATCH] handle newly added columns --- stand.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stand.py b/stand.py index 540202d..3a58a82 100644 --- a/stand.py +++ b/stand.py @@ -24,6 +24,12 @@ 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 + + print(">>> start of streamlit run") @@ -73,7 +79,7 @@ response = AgGrid( fit_columns_on_grid_load=True, reload_data=changed, - key="stand" + key=None if cols_changed else "stand" # None triggers a hard reload like F5, which is needed if new columns were added )