最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html table - Streamlit Aggrid column property rowSpan not working in Python - Stack Overflow

programmeradmin1浏览0评论

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)




发布评论

评论列表(0)

  1. 暂无评论