So after trying some stuff I just cant get it to work.
When using the ‘zIndex’ within a dcc.Dropdown(…) it seems to only apply to the top menu. When clicking it and expanding the options below they all seem to have a ‘zIndex’ of 0.
So setting it up for the dropdown menu doesnt really work.
I then tried to set up the table to have negative ‘zIndex’. When I do it within a header like this:
style_header={ 'zIndex': -100 },
it doesnt do anything. I guess it is having trouble with the fixed_rows property?
If I set the ‘z-Index’ of the whole table to -100:
style_table={ 'zIndex': -100 },
the dropdown options are finally in the foreground BUT suddenly the table is NOT editable anymore…
Can you share a reproducible example of the code you are working on?
Some thought that might help:
style_header probably will not work, because this is not about the style of the table’s container.
style_table: I think the same is valid, this is mainly about styling the table elements, but not the table and how it relates to other elements on the page/app.
Try putting each one of the elements in a special div and manage the zIndex there, it might be easier to figure out what is going on this way.
Here is some really simple code example that shows my problem:
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div([
dcc.Dropdown(
id='dropdpwon',
options=[
{'label': i, 'value': i}
for i in range(15)
],
style={'zIndex': 10},
value=5
),
],
style={'zIndex': 10}
),
html.Div([
dash_table.DataTable(
id='table_hno3',
columns=(
[{'id': 'datetime', 'name': 'datetime', 'editable': False}] +
[{'id': 'value', 'name': 'value', 'type': 'numeric'}]
),
data=[
dict({'datetime': i, 'value': 0})
for i in range(0, 49)
],
fixed_rows={'headers': True, 'data': 0},
style_table={
'height': 500,
'width': '250px',
'border': 'thin lightgrey solid'
},
editable=True,
)
],
style={'zIndex': -10}
)
]
)
if __name__ == '__main__':
app.run_server(debug=True)
The only way I have managed to get the table header into the background was with ‘style_table’ and the ‘zIndex’ but then the table is not clickable/scrollable/editable anymore…
Still desperately looking for a solution
It seems that setting zIndex needs to be done with a very high number, like 999 (I tried 300 for example but it doesn’t work). Not sure why, but it worked for me.
Also, you need to make sure to include another key in the style dictionary, which is for position: 'relative'.