简体   繁体   中英

Python Dash Table - How to embed href behind cell value

Dash table

Hi,

How can I embed the links into the product name columns so I can remove the link column? I'd like to access the links by clicking on the product name.

Any help would be greatly appreciated.

This is what I would do. I will first drop the Link column. Assuming df is your data.

df_drop_link = df.drop(columns='Link')

html.Table(
        # Header
        [html.Tr([html.Th(col) for col in df_drop_link.columns])] +

        # Body
        [html.Tr([
            html.Td(df.iloc[i][col]) if col != 'Product Name' else html.Td(html.A(href=df.iloc[i]['Link'], children=df.iloc[i][col], target='_blank')) for col in df_drop_link.columns 
        ]) for i in range(len(df))]
    ) 

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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