[BUG] merge_duplicate_headers breaks style_cell_conditional

Đang mở
#3,283 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@T4rk1n đang làm issue này rồi.

Từ ngày 3/6/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug P2

There were earlier bugs report regarding merge_duplicate_headers Issue1877 and it seems like there are still some left. I am not yet at 3.x but i found nothing regarding this in the changelog

dash                      2.18.2
dash-bootstrap-components 1.2.1
dash-core-components      2.0.0
dash-extensions           1.0.1
dash-html-components      2.0.0
dash-table                5.0.0

Describe the bug
Wrong black bold lines when using merge_duplicate_headers and style_cell_conditional.

Expected behavior
No bold black lines in the wrong columns.

Minimal Example

import dash
from dash import Dash, dash_table, html
import pandas as pd

# Sample data
data = {
    'Group A': ['Alice', 'Bob'],
    'Group A.1': [10, 20],
    'Group B': ['X', 'Y'],
    'Group B.1': [100, 200],
    'Group B.2': [1.1, 2.2]
}

# Create DataFrame
df = pd.DataFrame(data)

# Define columns with headers as lists for multi-level headers
columns = [
    {'name': ['Name', 'Person'], 'id': 'Group A'},
    {'name': ['Name', 'Score'], 'id': 'Group A.1'},
    {'name': ['Details', 'Code'], 'id': 'Group B'},
    {'name': ['Details', 'Value 1'], 'id': 'Group B.1'},
    {'name': ['Details', 'Value 2'], 'id': 'Group B.2'},
]

# Define style for bold black borders
style_cell_conditional = [
    {
        'if': {'column_id': col},
        'borderRight': '5px solid black',
        'fontWeight': 'bold'
    } for col in ['Group A.1', 'Group B.1']  # Columns to highlight
]

# Dash app
app = Dash(__name__)

app.layout = html.Div([
    dash_table.DataTable(
        data=df.to_dict('records'),
        columns=columns,
        merge_duplicate_headers=True,
        style_cell={'textAlign': 'center'},
        style_cell_conditional=style_cell_conditional
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)
Ngôn ngữ chính
Python
Star
24.4k
Fork
2.3k
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
13

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của plotly/dash

Tất cả issue của plotly/dash

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.