@Gbw-lucite Links are supported through the Markdown syntax. In markdowns, links take the form [display_name](url)
with both parts mandatory. If you have no meaningful name to display, just use the url like so: [url](url)
.
You can optionally add a hover title/description for the link like so: [display_name](url "title")
.
There are many good resources online for the Markdown syntax, here’s a demo from the 3rd party used by the DataTable to render markdowns: https://jonschlinkert.github.io/remarkable/demo/. That said, many sources of information exist and not all markdown implementations are created equal and some disparities are to be expected if looking at other sources.
For filtering, the table filters on the raw value of the field. The link in the example above (dict(a='[Dash documentation](https://dash.plot.ly)')
) will match both Dash
and plot.ly
.
Sorting is also done on the raw value of the field, not the displayed value. If for a certain column all rows contain similarly formatted links, this will behave the same as if sorting on the display value.
import dash
from dash_html_components import Div
from dash_table import DataTable
from pandas import DataFrame
def f(row):
return "[{0}]({0})".format(row["url"])
d = {
'id': [1,2,3,4,5,6],
'url': [
'www.google.com',
'dash.plot.ly',
'plot.ly',
'community.plot.ly',
'altavista.com',
'yahoo.com'
]
}
df = DataFrame(data=d)
df["link"] = df.apply(f, axis=1)
print(df)
app = dash.Dash(__name__)
app.layout = Div([
DataTable(
columns=[
dict(name='id', id='id', type='text'),
dict(name='link', id='link', type='text', presentation='markdown'),
],
data=df.to_dict('records')
),
])
app.run_server(debug=True)