dcc.store 用于实时约会数据 table DASH
dcc.store for live-dating data table DASH
我根据 editable DataTable https://dash.plotly.com/datatable/editable 上的文档对添加列函数实现了实时更新功能,以便在数据 table 中添加一个新列CSV 文件已更新。我有回调工作,我需要将数据 table 的状态保存在 dcc.store 中,这是向我推荐的,这样我就可以存储当前的列数,并且只添加基于新的 CSV 数据的新更新的列。我需要这样做,因为用户输入数据 table,如果我实时更新整个 table,数据就会丢失。我不知道我是否可以访问 dcc.store 中的用户输入数据,所以我只想向数据 table 添加新列,从而保留使用输入。
我的问题:有没有一种方法可以评估现有数据中的当前列数
table?
app.layout = html.Div([
dcc.Store(id='mystore'),
html.Div([dash_table.DataTable(
id='editing-columns',
columns=[{
'name': 'Parameter',
'id': 'column1',
'deletable': True,
'renamable': True
}],
},
data=[
{'column1': j}
for j in table_contents
],
]),
])
@app.callback(Output('mystore', 'data'),
Input('graph-update', 'n_intervals'),
State('editing-columns', 'data'))
def serve_layout(n,data):
print(data)
data2 = json.dumps(data)
return data2
输出
is there a way I can assess the current number of columns in an existing data table?
是的,您可以在 table 的 data
道具中阅读 State
。这将为您提供 table 中的所有内容,您可以轻松地从那里提取列数。
我根据 editable DataTable https://dash.plotly.com/datatable/editable 上的文档对添加列函数实现了实时更新功能,以便在数据 table 中添加一个新列CSV 文件已更新。我有回调工作,我需要将数据 table 的状态保存在 dcc.store 中,这是向我推荐的,这样我就可以存储当前的列数,并且只添加基于新的 CSV 数据的新更新的列。我需要这样做,因为用户输入数据 table,如果我实时更新整个 table,数据就会丢失。我不知道我是否可以访问 dcc.store 中的用户输入数据,所以我只想向数据 table 添加新列,从而保留使用输入。
我的问题:有没有一种方法可以评估现有数据中的当前列数 table?
app.layout = html.Div([
dcc.Store(id='mystore'),
html.Div([dash_table.DataTable(
id='editing-columns',
columns=[{
'name': 'Parameter',
'id': 'column1',
'deletable': True,
'renamable': True
}],
},
data=[
{'column1': j}
for j in table_contents
],
]),
])
@app.callback(Output('mystore', 'data'),
Input('graph-update', 'n_intervals'),
State('editing-columns', 'data'))
def serve_layout(n,data):
print(data)
data2 = json.dumps(data)
return data2
输出
is there a way I can assess the current number of columns in an existing data table?
是的,您可以在 table 的 data
道具中阅读 State
。这将为您提供 table 中的所有内容,您可以轻松地从那里提取列数。