Thanks it’s awesome !
when you delete the content of a cell it brings a
ValueError: could not convert string to float:
Traceback:
File “/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py”, line 332, in _run_script
exec(code, module.dict)
File “/app/streamlit-aggrid/example.py”, line 142, in
enable_enterprise_modules=enable_enterprise_modules
File “/app/streamlit-aggrid/st_aggrid/init.py”, line 138, in AgGrid
frame = frame.astype(non_date_cols)
File “/usr/local/lib/python3.7/site-packages/pandas/core/generic.py”, line 5533, in astype
col.astype(dtype=dtype[col_name], copy=copy, errors=errors)
File “/usr/local/lib/python3.7/site-packages/pandas/core/generic.py”, line 5548, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors,)
File “/usr/local/lib/python3.7/site-packages/pandas/core/internals/managers.py”, line 604, in astype
return self.apply(“astype”, dtype=dtype, copy=copy, errors=errors)
File “/usr/local/lib/python3.7/site-packages/pandas/core/internals/managers.py”, line 409, in apply
applied = getattr(b, f)(**kwargs)
File “/usr/local/lib/python3.7/site-packages/pandas/core/internals/blocks.py”, line 595, in astype
values = astype_nansafe(vals1d, dtype, copy=True)
File “/usr/local/lib/python3.7/site-packages/pandas/core/dtypes/cast.py”, line 997, in astype_nansafe
return arr.astype(dtype, copy=True)
You have to use the parameter cellRenderer in gb.configure_column. Then you create a javascript funcion to pass your image.
This is my code for the table. In my case I have a hide column name NATION_PATH where there is the path of the image that I use in LEAGUE column.
image_nation = JsCode("""function (params) {
var element = document.createElement("span");
var imageElement = document.createElement("img");
if (params.data.NATION_PATH) {
imageElement.src = params.data.NATION_PATH;
imageElement.width="20";
} else {
imageElement.src = "";
}
element.appendChild(imageElement);
element.appendChild(document.createTextNode(params.value));
return element;
}""")
gb.configure_column('LEAGUE', cellRenderer=image_nation)
I think this component (or component based on material UI)should be inbuilt into streamlit . The current method of displaying dataframe , when we have to display all data is not UI friendly
Wonderful! Good job Pablo!
Now I’m trying to use Grid Events on the table…for example click on a cell and open a popup…but this does not seem possible for now. Do you have a solution? Here the docs for events https://www.ag-grid.com/documentation/angular/grid-events/
Thanks in advance
I know that some grid features,such as csv downloading for instance, doesn’t work bc the grid is within an iframe and browsers have security policies in place. Maybe this is the case? Try using console.log first to see if your event is fired… if u want to share your code, send me the link and I can take a look later this week.