I have a small app displaying an AG-Grid table from an existing dataframe (the dataframe is originally a csv file read at the at the beginning of the app):
live_data = pd.read_csv('live_data.csv', index_col = 0)
app = Dash(__name__)
eurex_app.layout = html.Div([
dcc.Tabs([
dcc.Tab(label='Live', style=tab_style, selected_style=tab_selected_style, children=[
html.Br(),
dag.AgGrid(
id="live_table",
className="ag-theme-balham",
defaultColDef={"filter": True, "autoHeaderHeight": True, "floatingFilter": True},
columnSize="sizeToFit",
style={"height": 800, "width": '100%'},
rowData=eurex_live_datatable.to_dict("records"),
columnDefs=live_columns,
getRowStyle = getRowStyle,
dashGridOptions={"pagination": True, 'tooltipMouseTrack': True}),
dbc.Button("Refresh", id = 'refresh_button', n_clicks=0, style={'width' :'10%', 'fontWeight': 'bold', "margin-left": "850px", 'backgroundColor': '#F9F6EE', 'font-family':'Calibri', 'margin-top': '12px', 'border-color':'blue'})
]),
])
])
I added a button trying to use it to update the ag-grid table by reading the new csv:
@app.callback(Output('live_table', 'data'),
Input('refresh_button', 'n_clicks'),
prevent_initial_call = True)
def update_live(n_clicks):
if not n_clicks:
raise PreventUpdate
df = pd.read_csv('live_data.csv', index_col = 0)
live_data = format_live(df)
return live_data.to_dict("records")
It seems I am missing something…is there anything related to external downloads from the app…
I saw some explanations about some @app.server
connection to allow downloading CSV file in dash apps but can’t get my head on it. If anyone had this use case by the past…
Thanks
1