Hi @AnnMarieW !
Sure.
This is CSS in separate “assets” folder:
.dash-spreadsheet .row {
flex-wrap: nowrap;
}
.dash-spreadsheet.dash-freeze-left {
max-width: none !important;
}
.dash-spreadsheet .row {
margin-left: 0px;
margin-right: 0px;
}
And this it the full code of the WebApp. What this code does is it parses 4 different links depending on the dropdown option chosen (only 4 respective options available in dropdown) and then returns the Data_Table as html.Div(id=“data_table”)
I tried to change and experiment with the style_table{} parameter as you suggested but couldn’t find a solution.
import dash
from dash import dcc
from dash import html
from dash.dependencies import Input,Output
from dash import dash_table
import pandas as pd
import dash_bootstrap_components as dbc
from imdb import url_parser #module
app=dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP],
#following line with meta-tags allows the content to be viewable on mobile devices
meta_tags=[{"name":"viewpoints","content":"width=device-width,initial-scale=1.0"}])
app.layout=dbc.Container([
html.Div([
html.H1(
"Test Dashboard with Dash",
style={
"text-align":"center",
"color":"#503D36",
"font-size": 40
}
),
html.Div(id="memory-output1",style={"display":"none"})
]),
html.Br(),
dcc.Dropdown(
id="list1",
options=[
{"label":"Movies","value":"Movies"},
{"label":"Series","value":"Series"},
{"label":"Cartoons","value":"Cartoons"},
{"label":"Anime","value":"Anime"}
],
style={'color': 'black'}
),
html.Br(),
html.Div(id="data_table"),
],fluid = True)
@app.callback(
Output("data_table","children"),
Input("list1","value"),
prevent_initial_call=True
)
def store_data(dropdown_value):
if dropdown_value=="Movies":
url="https://www.imdb.com/list/..."
data=url_parser(url) #parse via imported module
data_table=dash_table.DataTable(
columns=[{'name': i, 'id': i,"type":"numeric","format":{"prefix":1000000,"specifier":",.0f"}} for i in data.columns],
data=data.to_dict("records"),
filter_action="native",
sort_action="native",
sort_mode="single",
# fixed_columns={'headers': True,'data': 1},
fixed_rows={'headers': True, 'data': 0},
page_action="native",
page_current=0,
page_size=100,
style_table={'minWidth': '100%', "height":300,"overflowY":"auto"},
style_header={"backgroundColor":"rgb(153, 203, 255)","fontWeight":"bold"},
style_cell={"backgroundColor":"rgb(239, 239, 243)","font-family": "Arial"},
style_as_list_view=True
)
elif dropdown_value=="Series":
url="https://www.imdb.com/list/..."
data=url_parser(url) #parse via imported module
data_table=dash_table.DataTable(
columns=[{'name': i, 'id': i,"type":"numeric","format":{"prefix":1000000,"specifier":",.0f"}} for i in data.columns],
data=data.to_dict("records"),
filter_action="native",
sort_action="native",
sort_mode="single",
# fixed_columns={'headers': True,'data': 1},
fixed_rows={'headers': True, 'data': 0},
page_action="native",
page_current=0,
page_size=100,
style_table={'minWidth': '100%', "height":300,"overflowY":"auto"},
style_header={"backgroundColor":"rgb(153, 203, 255)","fontWeight":"bold"},
style_cell={"backgroundColor":"rgb(239, 239, 243)","font-family": "Arial"},
style_as_list_view=True
)
elif dropdown_value=="Cartoons":
url="https://www.imdb.com/list/..."
data=url_parser(url) #parse via imported module
data_table=dash_table.DataTable(
columns=[{'name': i, 'id': i,"type":"numeric","format":{"prefix":1000000,"specifier":",.0f"}} for i in data.columns],
data=data.to_dict("records"),
filter_action="native",
sort_action="native",
sort_mode="single",
# fixed_columns={'headers': True,'data': 1},
fixed_rows={'headers': True, 'data': 0},
page_action="native",
page_current=0,
page_size=100,
style_table={'minWidth': '100%', "height":300,"overflowY":"auto"},
style_header={"backgroundColor":"rgb(153, 203, 255)","fontWeight":"bold"},
style_cell={"backgroundColor":"rgb(239, 239, 243)","font-family": "Arial"},
style_as_list_view=True
)
elif dropdown_value=="Anime":
url="https://www.imdb.com/list/..."
data=url_parser(url) #parse via imported module
data_table=dash_table.DataTable(
columns=[{'name': i, 'id': i,"type":"numeric","format":{"prefix":1000000,"specifier":",.0f"}} for i in data.columns],
data=data.to_dict("records"),
filter_action="native",
sort_action="native",
sort_mode="single",
# fixed_columns={'headers': True,'data': 1},
fixed_rows={'headers': True, 'data': 0},
page_action="native",
page_current=0,
page_size=100,
style_table={'minWidth': '100%', "height":300,"overflowY":"auto"},
style_data={
'width': '150px', 'minWidth': '150px', 'maxWidth': '150px',
'overflow': 'hidden',
'textOverflow': 'ellipsis',
},
style_header={"backgroundColor":"rgb(153, 203, 255)","fontWeight":"bold"},
style_cell={"backgroundColor":"rgb(239, 239, 243)","font-family": "Arial"},
style_as_list_view=True
)
return data_table
#Run the app
if __name__ == '__main__':
app.run_server(debug=True)