I have made this as well
defaultColDef =
{
"filter": True,
"wrapText": False,
"autoHeight": True,
"cellRenderer": "markdown"
},
without effect.
I have checked the behaviour on two machines, running an app in Chrome, the same.
Let me give you a minimal example. Do you experience the link to google being opened in a new tab?
#!~/env/bin/python
# coding: utf-8
## Dash board
import dash_ag_grid as dag
from dash import Dash, dcc, html, dash_table, callback, Input, Output
import pandas as pd
## Make a dummy dataframe
articles = pd.DataFrame(
{
'Гео': ['0'],
'Сектор': ['0'],
'Организация': ['0'],
'Ссылка': ['https://www.google.com/'],
'Язык': ['0'],
'Сообщение': ['0'],
'Время': ['0']
}
)
columnDefs = [
{'field': 'Гео', 'width': 100},
{'field': 'Сектор', 'width': 100},
{'field': 'Организация', 'width': 200},
{'field': 'Ссылка', 'width': 200, 'linkTarget': '_blank'},
{'field': 'Язык', 'width': 50},
{'field': 'Сообщение', 'width': 700},
{'field': 'Время', 'width': 200},
]
##Initialize the app
app = Dash()
#№ App layout
app.layout = html.Div([
html.Div(children = 'Новостной наблюдатель.'),
html.Hr(),
#html.Div(children = 'Период появления новостей равен последним трём часам.'),
html.Br(),
html.Div(children = 'Свежие новости.'),
dcc.Interval(
id = 'interval-component',
interval = 5000, # in milliseconds
n_intervals = 0
),
dag.AgGrid(
style = {"height": 1000, "width": 1900},
id = 'controls-and-table1',
rowData = articles.to_dict('records'),
columnDefs = columnDefs,
defaultColDef =
{
"filter": True,
"wrapText": False,
"autoHeight": True,
"cellRenderer": "markdown"
},
columnSize = "sizeToFit",
columnSizeOptions = {
'defaultMinWidth': 100
},
dashGridOptions = {"animateRows": True},
dangerously_allow_code = True
),
html.Br(),
html.Div(children = 'Выберите период отбора свежих новостей в часах:', style={'width': '400px'}),
html.Div(
children = dcc.RadioItems(options = ['1', '3', '6', '12', '24'], value = '1', id = 'controls-hours'),
style={'width': '300px'}
),
])
## Callbacks
@callback(
Output(component_id = 'controls-and-table1', component_property = 'rowData'),
Input(component_id = 'controls-hours', component_property = 'value'),
Input(component_id = 'interval-component', component_property = 'n_intervals')
)
def update_table1(hours, n_intervals):
articles = pd.DataFrame(
{
'Гео': ['0'],
'Сектор': ['0'],
'Организация': ['0'],
'Ссылка': ['https://www.google.com/'],
'Язык': ['0'],
'Сообщение': ['0'],
'Время': ['0']
}
)
articles['Ссылка'] = \
'[' + articles['Ссылка'] + ']' + '(' + articles['Ссылка'] + ')'
return articles[[
'Гео',
'Сектор',
'Организация',
'Ссылка',
'Язык',
'Сообщение',
'Время'
]].to_dict('records')
## Run
if __name__ == '__main__':
app.run(debug = True, host= '0.0.0.0', port = 7072)