Please make your table headings sticky
btxx.org
btxx.org
I felt really bad for the client because of how long it took. It also made me really careful with deciding on libraries when in Vue/React codebases. It's a very self-inflicted wound to require that much effort to do such a simple task. It's a table dangit, a HTML primitive, why am I like three JS classes deep and importing CSS as JSON?
Other cells have hover tooltips. And we need sort. Must have sort. And one of the table columns has editable values. But the edited value doesn’t affect the sort. It should affect the filter though. Did I mention we need filters? Also I need two sticky columns unless the user is a BobRole, then they should have 3 sticky columns and shouldn’t see column 9.
The table will have 50,000 rows with pagination. Pagination must respect the sort and filter obviously.
And there are more virtual-list libraries than I can count my.
My first port of call was bootstrap table classes (hoping for a class="table table-header-sticky") but there's nothing of the sort. I fiddled with suggestions from stack overflow, GPT and codepen in ~20 minutes only got sticky headers working with weird side effects on the rest of the table.
But in 2 minutes with the codepen from this article, I have it working. Pushing to prod now. Thank you!
I have a table with sticky head. Then I decide to add a memory feature, where if user scrolls the table body, and leaves the page, I'd save the index of the first visible row, and restore the scroll position when user comes back. I noticed that every time the restored position is always about one row too downward. For instance, when I want to restore to row 5, it restores to row 6 plus a few pixels. Turns out, once I turned the thead semi-transparent, I can see row 5 was indeed at the top of the table, but the thead just overlaps on top and making it look like row 6 is the first visible row.
I told myself, no problem, I just modify the scroll position to be aware of the thead's height. It worked fine at first, but from time to from it'd still be off a few pixels. Turns out, because the table is huge, I'm doing lazy loading upon the scroll event. And because I'm using the default automatic table layout (instead of the fixed layout), sometimes certain head cell becomes too narrow and word wraps, thus increases the whole head's height. The final solution is to create a ResizeObserver[1] on the thead element and dynamically adjust the scroll position if its height changes.
[1] https://developer.mozilla.org/en-US/docs/Web/API/ResizeObser...
table thead:before {
content: '';
position: absolute;
width: 100%;
top: 0;
border-top: 2px solid;
}
table thead:after {
content: '';
position: absolute;
width: 100%;
bottom: 0;
border-bottom: 1px solid;
}Unfortunately I'm seeing an increasing number of websites using 500 <div>s with 45 nested layers of <div>s within each <div> to create a table instead of <table>s so it wouldn't work on those.
why have everyone do extra work when one person could do it for everyone else in about the same amount of time that it would take one client to do?
Also, we already have a situation where different browsers have different defaults leading to an overall worse UX of the web.
So please, let's not do this.
I use tampermonkey, but I have it restricted to just one domain, which it complains about every time chrome is restarted.
Without it you get this behavior:
> heights | sort -k2 -nr
George 186
Wally 173
NAME HEIGHT
But if the headers bypass stdout then you get this instead: > heights | sort -k2 -nr
NAME HEIGHT
George 186
Wally 173This is a persistent limitation of the in-band text-only model. But I think this misuse of STDERR would be more confusing than helpful.
If `heights` was a file, you could do this:
% head -1 heights ; sed 1,1d heights | sort -k2 -nr
If `heights` is an executable that would be expensive to call twice: % heights > /tmp/heights ; head -1 /tmp/heights ; sed 1,1d /tmp/heights | sort -k2 -nr
Or you could pipe to `awk`, etc.Granted, these other options are less convenient, but they are also less surprising, and they work even if the executable creator has different ideas.
Sometimes you gotta do what you gotta do.
does the right thing.
I remember the browser support matrix showed almost all green when it didn't work for tables in Chrome.
Screenshots work on any device with a modern browser and usually I don't want to capture the entire page anyway but just specific interesting parts.
Sounds like your problem are not sticky headers but the "smart" semi-sticky ones that hide or show dynamically as you change scrolling direction, hiding content in exactly the place the user is looking at.
But TFA is about data tables with a sticky header column, a suggestion which really is genuinely useful.
Sticky headers and often a sortable fields functionality.
I've long wanted to see browsers offer modest spreadsheet-like features for tables. At the very least, the ability to sort, filter, summarise, and compute some simple statistical moments (mean, median, mode, standard deviation, possibly percentiles) of numeric ranges. Pivot tables might also be neat.
No reason this couldn't be a basic browser affordance.
Like in DataGridXL (https://datagridxl.com) disclaimer: I am the creator
Scroll the table down and up.
Scroll the table right and left.
Select some text in the table and copy it.
The component is used by a million+ end users and copies traditional Excel/Google Sheets controls.
Are you familiar with those programs?
DataGridXL is an Excel-like component for editing cell values, rather than a table component for selecting rows.
I am curious though if the component is somehow not working like Excel for you... will you perhaps take the time to do a screen recording? I am curious to know what you find awkward, as I especially take pride in the usability of the component. (robbert@datagridxl.com)
If you are browsing the Web today with ie11 then there's a lot of css that isn't going to work right.
And the impact of not supporting sticky is invisible - the table just works as it does now.
So there's no -techical- reason not to use it. At this point it's either a cosmetic choice (mostly for overflow reasons) or unawareness of its existence.
I've done this myself (usually with a gif though) because if I leave it as a exercise for the user to fiddle with 15% of them won't understand it.