simplified handling newly added columns
This commit is contained in:
8
stand.py
8
stand.py
@ -24,10 +24,8 @@ changed = restapi.changed
|
|||||||
df = restapi.data
|
df = restapi.data
|
||||||
|
|
||||||
|
|
||||||
columns = st.session_state.get("columns", set())
|
# encode the column names into the key, thus trigger a hard reload (like F5) when the columns change
|
||||||
new_columns = set(df.columns)
|
key = "stand:" + "+".join(str(col) for col in df.columns)
|
||||||
cols_changed = (columns != new_columns)
|
|
||||||
st.session_state.columns = new_columns
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ response = AgGrid(
|
|||||||
fit_columns_on_grid_load=True,
|
fit_columns_on_grid_load=True,
|
||||||
|
|
||||||
reload_data=changed,
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user