I’ve been following along this topic with this sample code:
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid
from st_aggrid import JsCode
from st_aggrid.grid_options_builder import GridOptionsBuilder
df = pd.read_csv(
"https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv"
)
# Display the DataFrame
gd = GridOptionsBuilder.from_dataframe(df)
gd.configure_column(
"airline",
headerName="airline",
cellRenderer=JsCode(
"""
function(params) {return `<a href="http://example.com/${params.value}" target="_blank">${params.value}</a>`}
"""
),
width=300,
)
grid_options = gd.build()
AgGrid(
df,
gridOptions=grid_options,
allow_unsafe_jscode=True,
# height=500,
theme="alpine",
)
The cell contents render like it’s a valueFormatter rather than a cellRenderer. I think I’m missing something, also mentioned in this topic.