question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

datatable fail to expand horizontally after 4.0.0 upgrade

See original GitHub issue

Problem

When upgrading Dash to v1.0.0 and Dash table (from 3.7.0) to 4.0.0, tables stop to auto-expand horizontally. In other words, they act as “<span>” instead of “<p>”.

with dash_table 3.7.0 Screenshot from 2019-07-03 15-31-56_shadow

with dash_table 4.0.0 Screenshot from 2019-07-03 15-33-16_shadow

The issue seems to come from the <table> HTML element. Indeed, its <div class="cell cell-1-1 dash-fixed-content"> container expands to the full width of it’s own parent. So if you manually set width: 100% to the <table> element, it works as expected.

However, it would be great to do this through the source code. But, unlike what is detailed here, the css attribute throws an error:

dash_table.DataTable(
    id='table',
    data=df.to_dict("rows"),
    columns=[{"name": i, "id": i} for i in df.columns],
    css={
        'width': '100%',
    },
),

and the style_table doesn’t solve the issue:

dash_table.DataTable(
    id='table',
    data=df.to_dict("rows"),
    columns=[{"name": i, "id": i} for i in df.columns],
    style_table={
        'width': '100%',
    },
),

Question(s)

Is it an expected behaviour?

If so, how to make table full (container’s) width again?


MWE

requirements for dash_table 3.7.0

dash-core-components==0.39.0
dash-html-components==0.13.2
dash-renderer==0.15.1
dash-table==3.7.0
dash==0.31.1
datetime
pandas==0.23.4
plotly==3.4.1

requirements for dash_table 4.0.0

dash_renderer==1.0.0
dash-core-components==1.0.0
dash-html-components==1.0.0
dash-table==4.0.0
dash==1.0.0
pandas==0.24.2
plotly==3.10.0

test app

import dash
import dash_table
import dash_html_components as html
import pandas as pd

df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv'
)

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        html.P(
            "foobar",
            style = {
                'background': 'cyan',
                'padding': '10px'
            }
        ),
        dash_table.DataTable(
            id='table',
            data=df.to_dict("rows"),
            columns=[{"name": i, "id": i} for i in df.columns],
        ),
    ],
    style = {
        'background': 'red',
        'padding': '10px'
    }
)


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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
chriddypcommented, Jul 5, 2019

If our default behaviour changed on this matter for 4.0.0, we should also update the documentation. image

However, I believe that the previous 3.x default behaviour (expanding to the parent container’s width) is the right behaviour here. So, we could consider this to be a bug & regression.

Also, once this gets fixed, let’s update this issue: https://community.plot.ly/t/how-to-make-datatable-has-width-100-after-4-0-0-upgrade/25145/4

0reactions
bpostlethwaitecommented, Jul 10, 2019

Cross posting a temporary fix for this for the people who end up here instead of https://community.plot.ly/t/how-to-make-datatable-has-width-100-after-4-0-0-upgrade/25145/6

adding this workaround as a dash-table property solved the issue for me as well as others

css=[{"selector": "table", "rule": "width: 100%;"}],
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make`DataTable` has width 100% after 4.0.0 upgrade?
Question. With Dash 1.0, How to make cells to auto-expand horizontally, so that the table fills up the entire horizontal space?
Read more >
Responsive Bootstrap Datatable not collapsing columns at the ...
It's a pretty straight forward problem. If I reduce the width of my window 1 more pixel the column will finally collapse. If...
Read more >
I need to programmatically add/remove fixed columns after ...
Issue is how do i access fixedcolums outside Datatable? var table = $('#example').DataTable( {... table.fixedColumns().left(2); <-- error
Read more >
mui-datatables - npm
<MUIDataTable />. The component accepts the following props: Name, Type, Description. title, array, Title used to ...
Read more >
DataTable component - Alfresco Builder Network
Raised on the 'keyup' event for the focused row. sorting-changed, Raised after user clicks the sortable column header. header-dragover, Raised when dragging ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found