Skip to content

whitespace on DataTable when merge_duplicate_headers= True #2870

Closed
@e-wallace

Description

Describe your context
To reproduce run the following. Toggle merge_duplicate_headers= True

import dash
import pandas as pd
import dash_design_kit as ddk
from dash import dash_table

data = {
    "indication": ["Indication 1", "Indication 2"],
    "y1-450-mg-iv": [100, 200],
    "y1-900-mg-iv": [150, 250],
    "y1-300-mg-sc": [120, 220],
    "y1-600-mg-sc": [130, 230],
    "y1-1800-mg-obi": [140, 240],
    "y1-1200-mg-obi": [160, 260],
    "y1-900-mg-obi": [170, 270],
    "y1-600-mg-obi": [180, 280],
    "y2-450-mg-iv": [105, 205],
    "y2-900-mg-iv": [155, 255],
    "y2-300-mg-sc": [125, 225],
    "y2-600-mg-sc": [135, 235],
    "y2-1800-mg-obi": [145, 245],
    "y2-1200-mg-obi": [165, 265],
    "y2-600-mg-obi": [185, 285]
}

fr_posology_table_data = pd.DataFrame(data)

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
                    id='posology-data',
                    data=fr_posology_table_data.to_dict('records'),
                    columns=[
                        {'id': 'indication', 'name': ['', 'Indication'], 'type': 'text', 'editable': False},
                        {'id': 'y1-450-mg-iv', 'name': ['Year 1', '450 mg IV'], 'type': 'numeric'},
                        {'id': 'y1-900-mg-iv', 'name': ['Year 1', '900 mg IV'], 'type': 'numeric'},
                        {'id': 'y1-300-mg-sc', 'name': ['Year 1', '300 mg SC'], 'type': 'numeric'},
                        {'id': 'y1-600-mg-sc', 'name': ['Year 1', '600 mg SC'], 'type': 'numeric'},
                        {'id': 'y1-1800-mg-obi', 'name': ['Year 1', '1800 mg OBI'], 'type': 'numeric'},
                        {'id': 'y1-1200-mg-obi', 'name': ['Year 1', '1200 mg OBI'], 'type': 'numeric'},
                        {'id': 'y1-900-mg-obi', 'name': ['Year 1', '900 mg OBI'], 'type': 'numeric'},
                        {'id': 'y1-600-mg-obi', 'name': ['Year 1', '600 mg OBI'], 'type': 'numeric'},
                        {'id': 'y2-450-mg-iv', 'name': ['Year 2', '450 mg IV'], 'type': 'numeric'},
                        {'id': 'y2-900-mg-iv', 'name': ['Year 2', '900 mg IV'], 'type': 'numeric'},
                        {'id': 'y2-300-mg-sc', 'name': ['Year 2', '300 mg SC'], 'type': 'numeric'},
                        {'id': 'y2-600-mg-sc', 'name': ['Year 2', '600 mg SC'], 'type': 'numeric'},
                        {'id': 'y2-1800-mg-obi', 'name': ['Year 2', '1800 mg OBI'], 'type': 'numeric'},
                        {'id': 'y2-1200-mg-obi', 'name': ['Year 2', '1200 mg OBI'], 'type': 'numeric'},
                        {'id': 'y2-600-mg-obi', 'name': ['Year 2', '600 mg OBI'], 'type': 'numeric'}
                    ],
                    fixed_columns={'headers': True, 'data': 1},
                    style_table={'minWidth': '100%', 'maxWidth': '100%'},
                    editable = True,
                    merge_duplicate_headers= True
                )

if __name__ == '__main__':
    app.run_server(debug=True)

requirements.txt

dash-design-kit==1.9.0
dash==2.14.1
gunicorn==20.0.4
pandas>=1.1.5

Describe the bug

When merge_duplicate_headers= True there is a large amount of whitespace to the right of the table. It is visible when going to the boundary of the scroll bar. This issue is present with both dash_table.DataTable and ddk.DataTable

Expected behavior
The boundary is expected to be at the end of the last column of the dataTable.

Screenshots
Here you can see the whitespace
Screen Shot 2024-05-29 at 1 01 00 PM

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokendash-data-tablerelated to DataTable componentsev-4cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions