[BUG] merge_duplicate_headers breaks style_cell_conditional

Aperta
#3,283 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@T4rk1n ci sta già lavorando.

Dal 3/6/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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)
Lingua principale
Python
Stelle
24.4k
Fork
2.3k
Merge medio
2g 7h
PR unite (30g)
13

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di plotly/dash

Tutte le issue di plotly/dash

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.