St_aggrid Hyperlink Render Issue but only on linux server

I have a dataframe with hyperlinks that I am rendering using st_aggrid. I am using the cellRenderer method to render the link column like so

 jsCodeLink = JsCode("""function(params) {return <a href="${params.value}" target="_blank"> Source Link </a>}""") 

and subsequently attaching the cellRenderer to the column like so

 builder.configure_column("Hyperlink",
                                headerName="Link",
                                cellRenderer= jsCodeLink,
                                width=100)

The issue is it works perfectly when deployed on windows server but not on linux. My main server is in linux and all dataframes with links are messed up due to this.

The link does not get decoded properly by the browser. This only happens in the case of linux server.
image

I have tried the following:

  1. I tired to write a replace function in JsCode but that did not work.
   jsCodeLink = JsCode("""
                        function(params) {
                            output = &lt;a href="${params.value}" target="_blank"&gt; Source Link &lt;/a&gt;;
                            var entities= {
                                "&amp;": "&",
                                "&lt;": "<",
                                "&gt;": ">"
                                //....
                            };
                            for (var prop in entities) {
                                if (entities.hasOwnProperty(prop)) {
                                    output = output.replace(new RegExp(prop, "g"), entities[prop]);
                                };
                            };
                            return output;
                        }
                        """)
  1. I set the streamlit markdown on initialisation. No luck.
st.markdown("<meta charset='UTF-8'>", unsafe_allow_html=True)
  1. Forced changed Linux server encoding to UTF-8. No luck either :frowning: :frowning: :face_with_head_bandage:

Spent whole day trying to fix this. Must be something simple silly fix. Any help would be greatly appreciated.

Thanks!

Any one with a potential solution?

On further investigation the issue seems to be with st_aggrid where the same cell renderer produces the correct hyperlink elements when deployed on Window but different a different output on Linux.

Windows : Output using the same renderer as above
image

Linux: Output using the same renderer as above

The client side is interpreting the links correctly on windows but somehow AG-GRID is telling client-side on linux to interpret it as string.

Unescaping does not help too.

Hey @helloworldofst,

Thanks for sharing this question – it might be worth also sharing this in the GitHub Issues section for streamlit-aggrid for @PablocFonseca to take a look if he has the time

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.