DataTable width on different screens

Viewed 66

I have this DataTable:

enter image description here

As you can see, the width looks good on my screen. However, some people complain that they have to use the right/left arrows to see the whole table.

At the moment I'm using vw units to define the table width, but the problem still remains. I don't know if there's a solution for this or if it depends on each screen resolution.

Hope you can help me. Thanks in advance.

1 Answers

One option is to make it so cell content spans multiple lines if there is not enough horizontal space.

Example given in the documentation:

dash_table.DataTable(
    style_cell={
        'whiteSpace': 'normal',
        'height': 'auto',
    },
    data=df_election.to_dict('records'),
    columns=[{'id': c, 'name': c} for c in df_election.columns]
)

See the documentation here for a lot of options on styling the width of a datatable.

Related