Open davecap opened 7 years ago
It isn't right now, but it would be nice to allow hooks into the cell renderer somehow.
A great resource and it would be useful to develop the following:
More sample code would be really useful too with the plotly Library.
I was able to use the following conditional formating idea to implement cell hyper link. https://community.plot.ly/t/coloured-text-in-a-table-conditional-formatting/7112/6
Here is my method - if you have columns like "ABCDE", column A and B are hyper link def ConditionalTable(dataframe): rows = [] hyper_link_col_list = ['A', 'B'] for i in range(len(dataframe)): row = {} for col in dataframe.columns: value = dataframe.iloc[i][col] if col in hyper_link_col_list: if "https" not in value: value = "https://"+value row[col] = html.Td(html.A(href=value, children=value)) else: row[col]=value rows.append(row) return rows
@app.callback(Output('table', 'rows'), [Input('field-dropdown', 'value')]) def update_table(user_selection): """ For user selections, return the relevant table """ df = get_data_object(user_selection) rows = ConditionalTable(df) df = pd.DataFrame(rows) return df.to_dict('records')
You need the following packages. dash==0.19.0 dash-core-components==0.16.0rc1 dash-html-components==0.9.0rc1 dash-renderer==0.13.0rc2 dash-table-experiments==0.6.0rc1
For table sorting and filtering on href links columns are not working since row[col] ={Td}Td('A') NOT row[col]= 'A'. This needs to be enhanced to be removed. row[col] = html.Td(html.A(href=value, children=value))
@aiy2018 How can we pass the Hyperlink value or dcc.Link component to another page?
@aiy2018 Did you implemented the Link into the cell?
Yes. The above code is working for link in the cells except that the cell data cannot be sorted. I have not done passing the Hyperlink value to another page.
Is it possible to embed links as cell values?