i have a css and javascript to freeze first column in a html table, and it is tested in [codepen] (https://codepen.io/zh1611/pen/bjaEKJ) but when i move it to my dash app, it is not working as expected.
html.Table([
html.Thead([html.Tr([html.Th(col, style={‘textAlign’:‘center’, ‘fontSize’:‘16px’, **table_colors[‘header’]}) for col in df1.columns])]),
html.Tbody(rows)
], className=‘main-table’)
i will consider change my dash-app code using this approach. but i am still scratching my head why the css/js combination work in codepen but not in my app. the html structure look-alike.
the answer from stackoverflow, this could be due to the table was dynamically created, that’s why the js script cannot find the object hence no effect.
after spent some time googling and stackoverflowing i finally found a solution…it seems simple problem in the first glance but ends up i bumped into some new terms: event bubbling, event delegation …etc. let me know if you have better solution.
For all of the folks finding this on Google, this is now a built-in feature of the DataTable called fixed_columns, see https://dash.plotly.com/datatable for examples.