moved customized aggrid into separate file
This commit is contained in:
36
aggrid.py
Normal file
36
aggrid.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from st_aggrid import AgGrid, GridOptionsBuilder
|
||||||
|
|
||||||
|
from utils import make_key
|
||||||
|
|
||||||
|
|
||||||
|
def aggrid(df, reload_data=False):
|
||||||
|
df = df[::-1] # display in reversed chronological order
|
||||||
|
|
||||||
|
gob = GridOptionsBuilder.from_dataframe(
|
||||||
|
df,
|
||||||
|
editable=True,
|
||||||
|
filterable=True,
|
||||||
|
groupable=True,
|
||||||
|
resizable=True,
|
||||||
|
sortable=True
|
||||||
|
)
|
||||||
|
|
||||||
|
gob.configure_auto_height(True)
|
||||||
|
go = gob.build()
|
||||||
|
|
||||||
|
response = AgGrid(
|
||||||
|
df,
|
||||||
|
go,
|
||||||
|
theme="streamlit",
|
||||||
|
fit_columns_on_grid_load=True,
|
||||||
|
reload_data=reload_data,
|
||||||
|
key=make_key(df)
|
||||||
|
)
|
||||||
|
|
||||||
|
df = response.get("data", df)
|
||||||
|
response["data"] = df[::-1] # undo reversed chronological order
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
31
stand.py
31
stand.py
@ -1,10 +1,9 @@
|
|||||||
import streamlit as st
|
import streamlit as st
|
||||||
from st_aggrid import AgGrid, GridOptionsBuilder
|
|
||||||
|
|
||||||
import hacks
|
import hacks
|
||||||
|
|
||||||
|
from aggrid import aggrid
|
||||||
from restapi import restapi
|
from restapi import restapi
|
||||||
from utils import make_key
|
|
||||||
from utils.st_utils import get_session_id, rerun, hide_UI_elements
|
from utils.st_utils import get_session_id, rerun, hide_UI_elements
|
||||||
from utils.df_utils import to_excel_binary
|
from utils.df_utils import to_excel_binary
|
||||||
|
|
||||||
@ -56,35 +55,13 @@ with col1:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
gob = GridOptionsBuilder.from_dataframe(
|
response = aggrid(
|
||||||
df,
|
df,
|
||||||
editable=True,
|
reload_data=changed
|
||||||
filterable=True,
|
|
||||||
groupable=True,
|
|
||||||
resizable=True,
|
|
||||||
sortable=True
|
|
||||||
)
|
|
||||||
|
|
||||||
gob.configure_auto_height(True)
|
|
||||||
go = gob.build()
|
|
||||||
|
|
||||||
#st.write(go)
|
|
||||||
|
|
||||||
response = AgGrid(
|
|
||||||
df[::-1],
|
|
||||||
go,
|
|
||||||
|
|
||||||
theme="streamlit",
|
|
||||||
|
|
||||||
fit_columns_on_grid_load=True,
|
|
||||||
|
|
||||||
reload_data=changed,
|
|
||||||
key=make_key(df)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
new_df = response.get("data")#, df)
|
new_df = response["data"]
|
||||||
new_df = new_df[::-1]
|
|
||||||
if not new_df.equals(df) and not changed:
|
if not new_df.equals(df) and not changed:
|
||||||
restapi.data = new_df
|
restapi.data = new_df
|
||||||
# print("old:")
|
# print("old:")
|
||||||
|
Reference in New Issue
Block a user