I would like to keep columns on the client side but hide them from the view.
I have a few use cases, but the one I am trying to implement right now is for rows to have conditional formatting based on data the user doesn’t want to see. Therefore the data needs to be there client side, but just not visible to the user.
However honestly I find the documentation site a little difficult to naturally read through compared to most other Python documentation sites. By structuring the reference as a table and giving the Type column such little width some of the columns are 33 lines long where each line is 1 - 3 words long.
Most other components from Dash I just read the documentation directly out of the docstring by ctrl + clicking on the object in PyCharm, and that’s always been sufficient but this isn’t possible with DataTable.
For the use case where you simply don’t want to display the data you can remove the column from the “columns” prop and it will disappear from the table, it will ignore all data with that field.
dash_table.DataTable(
id=‘crawledtable’,
columns=[{“name”: i, “id”: i} for i in table.columns],
data=table.to_dict(‘records’),
row_selectable=“multi”,
selected_rows=[],
sort_action=“native”,
sort_mode=“multi”,
style_cell_conditional=[
{
‘if’: {‘column_id’: c},
‘display’: ‘none’
} for c in [‘Date’, ‘Region’]
],
For anyone who is coming to this page, another method hidden_columns property of the table. When you set the style to none the cell is shown in the TOGGLE COLUMN as marked and there won’t be any way to see it. But when you set the hidden_columns = ['Date', 'Region'], those columns are shown as unchecked in the TOGGLE COLUMN (it’s a button above the table that shows a list of the columns) so the user can check them to show those columns.
It really depends on the use case which method to use, for me this was a better approach.