Horizontal scrolling and the Fixedheader briefly losing alignment

Horizontal scrolling and the Fixedheader briefly losing alignment

silkspinsilkspin Posts: 155Questions: 35Answers: 5

I’ve been trying to get a way of using fixedheaders on a wide table for a couple of days. I finally managed to get it working the same on desktop and mobile (I don’t want this to be responsive), but there is one slight problem. If the screen is scrolled when anywhere except the absolute left of the table, once the fixedheader is attached, it starts at the left, so it appears out of line. However, what causes it to realign straight away, is to just scroll horizontally either left of right and it suddenly jumps back into position. When you scroll back up and the fixedheader detaches once again, the problem above is repeated.

I’ve tried loads of suggestions with no luck including table.columns.adjust() and table.fixedHeader.adjust();.

I use the table inside a div to contain it, and this nearly works as I wanted.

<div style="overflow: auto; max-width: 100%;">
    <table class="datatable table table-striped table-bordered" id="datatable" style="width: auto; margin: 0;">

I’ve read about scrollX and fixedheaders not being being 100% compatible, but I seem to be so close to this working after trying so many combinations.

I use Bootstrap 5 and have all the latest versions from the downloads page. I have fixedHeader: true, scrollX: true,.

Is there a way something can be triggered to fix this like just a quick horizontal scroll does? I’ve attached a couple of demo screenshots and I’m hoping there might be something I can try without the need for a test case. I hope I’ve given enough detail.



This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.