Fake table headers and forced vertical scroll


I know a number of folks have tried to solve this or similar problems. I have a table where I’m using a “fake column header” which is just another table stacked on top. I’ve seen solutions for this where “you must use fixed widths”. This is not true for my solution. I have both fixed and variable column widths and the table as a whole is “full size”.

The trouble comes in with dynamic scroll bars. When scrolling is not required, column alignment is perfect. When scroll bars are required, the lower table (the “list”) is shrunk horizontally to make room for the scroll bar. This breaks alignment. Forcing a permanent scroll bar on the list table doesn’t work. I don’t recall why. I also tried putting the list table in a panel but that didn’t help.

Ultimately I used a CustomLayout to solve the problem. My fake header table has the last column defined like so:

tblFakeHeader.setColumnWidth(PROP_ID_SCROLL, -1); // let theme set the width, whatever that means, amounts to 10px plus padding, border

This provides a buffer that will be the same width as the scroll bar. The fake header table is placed in a vertical layout followed by the custom layout which then contains the list table.