diff --git a/stand/webapp.py b/stand/webapp.py index 53428b4..5b71452 100644 --- a/stand/webapp.py +++ b/stand/webapp.py @@ -39,6 +39,13 @@ auto_height = st.sidebar.checkbox( key="auto_height" ) +pagination = st.sidebar.checkbox( + "Pagination", + value=True, + disabled=auto_height, + key="pagination" +) + height = st.sidebar.slider( "Grid Height", min_value=100, max_value=1500, value=500, step=10, @@ -47,6 +54,7 @@ height = st.sidebar.slider( ) if auto_height: + pagination = False # would only show "1 of 1" height = "auto" @@ -56,6 +64,7 @@ if auto_height: response = aggrid( df, reload_data=changed, + pagination=pagination, height=height ) diff --git a/stand/widgets/aggrid.py b/stand/widgets/aggrid.py index 48c72bd..60a680e 100644 --- a/stand/widgets/aggrid.py +++ b/stand/widgets/aggrid.py @@ -1,7 +1,7 @@ from st_aggrid import AgGrid, GridOptionsBuilder -def aggrid(df, reload_data=False, height="auto"): +def aggrid(df, reload_data=False, height="auto", pagination=True): df = df[::-1] # display in reversed chronological order gob = GridOptionsBuilder.from_dataframe( @@ -15,6 +15,7 @@ def aggrid(df, reload_data=False, height="auto"): enable_auto_height = (height == "auto") gob.configure_auto_height(enable_auto_height) + gob.configure_pagination(pagination) go = gob.build() @@ -25,7 +26,7 @@ def aggrid(df, reload_data=False, height="auto"): theme="streamlit", fit_columns_on_grid_load=True, reload_data=reload_data, - key=make_key(df, enable_auto_height) + key=make_key(df, enable_auto_height, pagination) ) df = response.get("data", df) @@ -35,14 +36,15 @@ def aggrid(df, reload_data=False, height="auto"): -def make_key(df, enable_auto_height): +def make_key(df, enable_auto_height, pagination): """ encode the dataframe's column names into a key, - as well as the state of the auto height setting, - this triggers a hard reload (like F5) of the AgGrid if the columns/setting change + as well as the state of the auto height and pagination settings, + this triggers a hard reload (like F5) of the AgGrid if the columns/settings change """ items = list(df.columns) items.append(enable_auto_height) + items.append(pagination) return "stand:" + "+".join(str(i) for i in items)