I’m having a problem with my datatable. Whenever I introduce a scrollbar, the first column of that datatable is cut. Look at the code below:
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/solar.csv')
app = dash.Dash(__name__)
app.layout = html.Div(
dash_table.DataTable(
id='table',
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict('records'),
editable = True,
row_selectable='multi',
#row_deletable=True,
#fixed_columns={ 'headers': True, 'data': 1 },
style_cell={'textAlign': 'center'},
style_table={
'overflowX': 'scroll',
'minWidth': '100%',
'padding-bottom': '10px',},
),
style={'padding': '30px'}
)
if __name__ == '__main__':
app.run_server(debug=True)
This produces the image below, which is the problem:
The first select-checkbox-column is cut (This behaviour is the same even when the first column is a normal column).
However, if I tweak the code to remove the styling responsible for the scrollbar, the table behaves as expected:
app.layout = html.Div(
dash_table.DataTable(
id='table',
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict('records'),
editable = True,
row_selectable='multi',
#row_deletable=True,
#fixed_columns={ 'headers': True, 'data': 1 },
style_cell={'textAlign': 'center'},
# style_table={
# 'overflowX': 'scroll',
# 'minWidth': '100%',
# 'padding-bottom': '10px',},
),
style={'padding': '30px'}
)
I’ve tried padding the table, as well as padding the div the table is contained in but it doesn’t seem to help. This is driving me nuts as the table in my actual app depends on that checkbox column appearing properly. Why is “overscrollX” producing this problem and how do I fix it?