Open
Description
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)