如何在破折号数据表的列字段中添加超链接 [英] How to add hyperlink in column field of dash Datatable

查看:68
本文介绍了如何在破折号数据表的列字段中添加超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将超链接添加到第一列 CR-number,所以它应该是可点击的,点击它会重定向到链接.

I wanted to add Hyperlink to the first column CR-number, so it should be clickable, on clicking it will redirect to the link.

下面是它的代码片段.

html.Div(
        className = "row",
        children = [
            dash_table.DataTable(
                id='datatable-cr-list',
                columns=[
                    {"name": i, "id": i} for i in cr_columns_to_display
                ],
                filter_action = "native",
                sort_action = "native",
                style_cell_conditional=[
                        {'if': {'column_id': 'Title'},
                        'textAlign': 'left',
                        'overflow': 'hidden',
                        'textOverflow': 'ellipsis',
                        'width': '60%',
                        'whiteSpace': 'normal'
                        }
                ],
                style_data_conditional=[
                    {
                        'if': {'row_index': 'odd'},
                        'backgroundColor': 'rgb(230, 242, 255)'
                    }
                ],
                style_header={
                    'backgroundColor': 'rgb(153, 204, 255)',
                    'fontWeight': 'bold'
                },
                export_format="csv",
            )
        ]
    ),

这是表格的图像,我想在其中向第一列添加超链接.我们是否有任何功能可以向破折号添加超链接?

here is the image of the table, where I wanted to add a hyperlink to the first column. Do we have any feature to add a hyperlink to the dash?

推荐答案

我修复了使用以下方法向第一列添加超链接并在表格字段的布局中添加presentation":'markdown'

I fix with adding hyperlink to first column with below method and add "presentation": 'markdown' in the Layout for Table field

def f(row):
    return "[{0}](<link of redirection>{0})".format(row["CR_Number"])
if open_cr_count > 0:
    df_fa_direct_open["CR_Number"] = df_fa_direct_open.apply(f, axis=1)

这篇关于如何在破折号数据表的列字段中添加超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆