Is it possible to add a hyperlink to a single cell in an AG-Grid Table, using streamlit-aggrid? I have previously used the following code to create clickable hyperlinks for all cells within a column, but I am not sure how to do it for a single cell in a column.
Your concept is correct: create the cellRenderer as JsCode and then pass it in to ‘configure_column’ as the cellRenderer param, and you do have to say which column you are configuring.
There is a syntax error in the JS in the post, I don’t know if that was a copy and paste error or if that is contributing to your issue?
Many thanks for your reply. Sorry - I think that was a cut and paste error.
I have no problem configuring a whole column so that all entries are hyperlinks. However, my problem is that I would like to designate a single cell within the column as a hyperlink. (None of the other cells in the column are hyperlinks). Do I still need to use configure_column or should this be done in a different way?
It is possible but it would be done using other properties in the params either for a specific value, or if the cell was part of the row.
the params provides access to the full grid API and the column API so you can use that to conditionally decide to return html for a link or for just the value:
AG Grid also has the concept of cellRendererSelectors
Which allow use of different selectors, with the condition being performed at the selection stage rather than in the cellRenderer itself.
But… AG Grid does not have a way of assigning a specific cellRenderer to a specific cell, the cellRenderer or cellRendererSelector would use the APIs or the values in params like the rowNode, data, column definition etc. to decide what rendering to use.
So you might look at the value and if it can be converted to a URL without throwing an exception new URL(string) then return the <a>...</a> otherwise just return the params.value.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.