Conditional for entire table

DataTable(
                                        columns=[
                                            {"name": "Year", "id": "year"},
                                            {"name": "0", "id": "0", "hideable": True},
                                            {"name": "1", "id": "1", "hideable": True},
                                            {"name": "2", "id": "2", "hideable": True},
                                            {"name": "3", "id": "3", "hideable": True},
                                            {"name": "4", "id": "4", "hideable": True},
                                            {"name": "5", "id": "5", "hideable": True},
                                            {"name": "0 - 2", "id": "0-2", "hideable": True},
                                            {"name": "3 - 5", "id": "3-5", "hideable": True},
                                            {"name": "0 - 5", "id": "0-5", "hideable": True},
                                        ],

...

                                    export_headers='display',
                                    merge_duplicate_headers=True,
                                    selected_rows=[],
                                    sort_action='native',
                                    sort_mode='multi',
                                    hidden_columns=dt_id_list_off,
                                    style_table={
                                        'overflowX': 'scroll'
                                    }

Columns for this table can be added or removed. There’s currently a horizontal scroll bar on my table, but I’d like it to only appear if the table overflows, or the number of columns is < 5 (which is when it overflows.) I haven’t been able to find a way to do this using style_data_conditional and would appreciate advice.

Cheers!

Hi @BrotherTheresa and welcome to the Dash community :slightly_smiling_face:

Try changing it to:

style_table={'overflowX': 'auto'}
1 Like