Open chriddyp opened 4 years ago
I am also experiencing this bug. Hope this will get noticed and fixed since this really complicates the straightforward style logic!
@chriddyp please let us know when this issue is resolved. Thanks a lot.
I got the same error today with dash-table==4.11.3
. The workaround doesn't work for me, as I have a mix of left-aligned and right-aligned columns.
The WA here works for now. Adding the snippet in python way to specify CSS https://github.com/plotly/dash-table/issues/694#issue-566609561
dash_table.DataTable(
id='datatable-interactivity',
columns=[
{"name": i, "id": i} for i in thresholded_df.loc[:,['ds_org','y_org']]
],
style_filter={'textAlign': 'left'},
style_cell={'textAlign': 'left'},
data=thresholded_df.to_dict('records'),
css=[{
'selector': '.dash-spreadsheet td div',
'rule': '''
line-height: 15px;
max-height: 30px; min-height: 30px; height: 30px;
display: block;
overflow-y: hidden;
''' ,
'selector': '.dash-filter input' ,
'rule': '''
text-align: left !important;
padding-left: 5px !important;
'''
}],
style_table={'overflowX': 'auto'}
),
html.Div(id='datatable-interactivity-container'),
])
Got the same issue but used a different workaround:
.dash-filter input {
text-align: inherit !important;
}
This way the text alignment default for inputs is overriden with the parent th
property, which is provided by the cell style. So used in combination with style_cell_conditional
it allows to text-align the filter just as the rest of the data, with right/left mix (solving @amarvin limitation above):
style_cell_conditional=[
{"if": {"column_id": "left_col_1"}, "textAlign": "left"},
{"if": {"column_id": "left_col_2"}, "textAlign": "left"},
{"if": {"column_id": "right_col_2"}, "textAlign": "right"},
]
Only tested in Firefox 102.0
/ dash-table-5.0.0
My columns are left aligned rather than right aligned:
I'd expect that the filter's alignment would match the column's by default. So, my left aligned columns would have left aligned filter inputs.
Currently, the workaround is to override this in CSS:
(Note that
style_filter={'text-align': 'left', 'padding-left': '5px'}
doesn't get applied to the input element and so it doesn't work either.)