Is there a way to fix only the last row in datatable?

Hi, I want to fix the total row of datatable

I have tried this property but it fix rows from top to bottom:
fixed_rows={'headers': True, 'data': 1}

and as I said, I want the opposite

Hello @abdoo,

Why are you trying to fix the last row, is it going to be a subtotal or something?

Typically, you wouldnt fix the bottom unless your table is confine to a specific height. Fixing normally implies that it is going to be at a logical position, ie {'position':'sticky'} this becomes more difficult when you add a dynamically adjusted height element and you want it to be at the bottom.

actually my datatable has only 18 rows and I have tried a lot ways to make the page display
all rows (that is WHAT I WANT) but it’s just didn’t work.

I agree with you, it’s not a good idea to fix just one row, so how can I force the page to display
all the table ?

Are you able to show the code where you are building the datatable?

yes, this in the layout:
html.Div(id='table-id', style={'margin-left': '55px', 'margin-top': 30, 'height': '80vh', 'overflowY': 'hidden'})

and this is in the callback:

table = dash_table.DataTable(
    # id="table",
    columns=[{"name": str(i), "id": str(i)} for i in table_data.columns],
    style_header={'whiteSpace': 'normal', 'fontWeight': 'bold'},
    fixed_rows={'headers': True},

Take out the fixed_rows argument. It causes issues sometimes, if you need to freeze the top columns, I can give you a css argument for that.

Your table has 18 rows of data?

You can also add a style_table={'maxHeight':'79vh','height':'79vh'} to the table.


brother, this was amazing it worked like charm . thank you

1 Like