PablocFonseca / streamlit-aggrid

Implementation of Ag-Grid component for Streamlit
https://pypi.org/project/streamlit-aggrid/
MIT License
1.06k stars 202 forks source link

Have hyperlinks as cell entries in ag-grid through python #17

Closed gyanendrasharma closed 2 years ago

gyanendrasharma commented 3 years ago

I was wondering if there was a way to have hyperlinks as cell entries in ag-grid through python alone. I am trying to display a table where the cell entries would be clickable links and I would like to accomplish this entirely through the python script. Is this something that is currently available or are there known solutions? Thank you!

leonqli commented 3 years ago

@gyanendrasharma Have you figured it out how to add clickable hyperlinks in the table? I've same problem using it. Thanks!

gyanendrasharma commented 3 years ago

@leonqli unfortunately, I couldn't and ended up using HTML tables instead. Would be definitely nice to have it though.

leonqli commented 3 years ago

Thanks @gyanendrasharma!

leonqli commented 3 years ago

Hi @gyanendrasharma ,

I figured out the following way may to insert hyperlink in ag-grid, in case you need it in the future.

from st_aggrid import JsCode

gb.configure_column("link",
                            headerName="Link",
                            cellRenderer=JsCode('''function(params) {return '<a href="https://www.google.com">params.value</a>'}'''),
                            width=300)
gyanendrasharma commented 3 years ago

Awesome. Thanks @leonqli This should be helpful.

mtsardakas commented 2 years ago

The example above is very useful - could we also incorporate each cell's data to the hyperlink?

leonqli commented 2 years ago

Try to modify your code similar to the following way (you may need to change it to your URL):


cellRenderer=JsCode('''function(params) {return '<a href="https://www.google.com/' + params.value + '" target="_blank">'+ params.value+'</a>'}''')```