Im trying to merge cells with the same value in Streamlits Ag-grid using Python, when I use the rowSpan = True property it gives me an error this.colDef.rowSpan is not a function. This is the code:
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder
import pandas as pd
# Sample DataFrame
data = {
'Category': ['A', 'A', 'B', 'B', 'B', 'C'],
'Value': [10, 20, 30, 40, 50, 60]
}
df = pd.DataFrame(data)
# Configure AgGrid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_column("Category", rowSpan=True, cellClassRules={
'cell-span': 'value !== undefined'
})
gb.configure_column("Value")
grid_options = gb.build()
# Apply custom CSS to handle cell spanning
st.markdown("""
<style>
.ag-cell.cell-span {
background-color: #f0f0f0;
border-bottom: 1px solid #d0d0d0;
}
</style>
""", unsafe_allow_html=True)
# Display the grid
AgGrid(df, gridOptions=grid_options, allow_unsafe_jscode=True)