PablocFonseca / streamlit-aggrid

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

html rendering fails #244

Closed isaaccs closed 8 months ago

isaaccs commented 8 months ago

I have a dataset containing HTML code in a column, I use the following function combined with the cellrender argument to display it in HTML view

html_view = JsCode("""
function (params) {
    return params.value;
};
""")
gb.configure_column("html_col", editable=True, autoHeight=True, cellRenderer =html_view )

rendering seems to fail because the following file is missing

2023-10-24 11:18:50.514 ComponentRequestHandler: GET /venv/lib/python3.10/site-packages/st_aggrid/frontend/build/bootstrap.min.css.map read error
Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/streamlit/web/server/component_request_handler.py", line 55, in get
    with open(abspath, "rb") as file:
FileNotFoundError: [Errno 2] No such file or directory: '/venv/lib/python3.10/site-packages/st_aggrid/frontend/build/bootstrap.min.css.map'

do you have an idea to fix this problem

isaaccs commented 8 months ago

This is my solution

HtmlCellRenderer = JsCode(
    """
class HtmlCellRenderer {
    init(params) {
        this.params = params;
        this.eGui = document.createElement('div');
        this.eGui.innerHTML = params.value;
    }

    getGui() {
        return this.eGui;
    }

    refresh() {
        return true;
    }

    destroy() {
    }
}
"""
)