Hi all,
I’d like to know how I can include the contents of a DataTable in a Form submission.
Following from the example given here, I’ve included a simple table as part of the form:
import flask
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
app = dash.Dash(__name__)
app.layout = html.Form([
dcc.Input(name='name'),
dash_table.DataTable(id='table',
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict('records')),
html.Button('Submit', type='submit')
], id='input_form', action='/post/', method='post')
@app.server.route('/post/', methods=['POST'])
def post():
data = flask.request.form # I want 'data' to contain the contents of my table
print(data)
return flask.redirect('/')
In the above code snippet the dcc.Input(name='name') gets sent with the Form, but not the contents of the table.
Question is: how do I get the contents of the DataTable to be sent as part of the form submission?
Cheers.