Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed columns in dash data table breaks layout spread

I’m trying to set the two first columns of my table

I want the two first columns of my table to be fixed
but when I set the fixed_columns component the entire layout gets very small
I am using dash 1.13 (but also tried 1.12)
A small as possible code to reproduce my problem:

import dash
import dash_table
import random

def define_table():
    headers = ['Fixed1', 'Fixed2', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
    columns = [{'name': h, 'id': h} for h in headers]
    data = []
    for i in range(0, 20):
        row = {}
        for h in headers:
            row[h] = random.random()
        data = data + [row]
    return dash_table.DataTable(
        id='table-results',
        data=data,
        columns=columns,
        fixed_columns={'headers': True, 'data': 2},  # TODO
        style_cell={'textAlign': 'left'},
        row_deletable=True,
        export_columns='visible',
        export_format='csv')


app = dash.Dash(__name__)
app.layout = define_table()

if __name__ == '__main__':
    app.run_server(debug=True)

A picture of how it looks at my browser:

On Firefox1

like image 358
ItamarG Avatar asked Oct 16 '25 16:10

ItamarG


1 Answers

from:
https://community.plotly.com/t/fixed-columns-in-dash-data-table-breaks-layout-spread/42361
adding style_table={'minWidth': '100%'} to the table attributes fixed it

like image 135
ItamarG Avatar answered Oct 18 '25 06:10

ItamarG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!