我可以在Callback生成的数据表中使用超链接来使用传递的数据打开模式吗?

2024-04-19 13:29:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用一个dbc.Modal和一个链接到调用POST请求的回调的Submit按钮在DataTable中创建记录(有8个字段,为了简洁起见,只显示了2个字段):

html.Div([
    dbc.Modal([
        html.Tr([html.Td('Author(s):', id='country-source-author-label'),
        html.Td(dcc.Textarea(id='country-source-author-textarea')
        ]),
        html.Tr([html.Td('Publication Date:',
        html.Td(dcc.DatePickerSingle(id='country-source-publication-date-picked')])
    ], id='add-country-source-modal'),
    dbc.Button("Submit", id='add-country-source-submit-button'))
])

以下是此表单生成的示例数据: county_source_table = ['author_name': 'E.O. Wilson', 'date': '2021-10-31', 'link': '#']

要查看源代码,我有一个DataTable,其中包含指向详细信息列中单个记录的超链接

sources_table = dash_table.DataTable(
    id='county-source-table',
    columns=[
        {'id': 'author_name', 'name': 'Author'},
        {'id': 'date', 'name': 'Publication Date'},
        {'id': 'link', 'name': 'Details', 'type': 'text', 'presentation': 'markdown'}
    ], 
    markdown_options={'link_target': '_self'})

我想做的是单击表中每个记录的链接,打开包含该记录所有相关数据的Dash Bootstrap模式,比如this。我被难住了,有什么想法吗