繁体   English   中英

dcc.store 用于实时约会数据表 DASH

[英]dcc.store for live-dating data table DASH

I implemented a live-update feature to the add column function based on the documentation on editable DataTable https://dash.plotly.com/datatable/editable such that a new column is added to the datatable when the CSV file is updated. 我已经得到了回调工作,我需要将数据表的 state 保存在 dcc.store 中,这是向我推荐的,以便我存储当前的列数,并仅添加新更新的列基于新的 CSV 数据。 我需要这样做,因为用户在表中输入数据,如果我实时更新整个表,数据就会丢失。 我不知道我是否可以访问 dcc.store 中的用户输入数据,因此我只想将新列添加到数据表中,从而保留使用输入。

我的问题:有没有办法可以评估现有数据表中的当前列数?

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

Output


有没有办法可以评估现有数据表中的当前列数?

是的,您可以在表格的data道具中读取为State 这将为您提供表格中的所有内容,您可以轻松地从那里提取列数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM