Colspan in Grid?

In Vaadin 8 Grid the columns could easily be make hidable by calling setHidable(true). This would render a context menu in the table header like this:

image

Now I want to do the same thing in Vaadin 24. There is no setHidable() anymore, so I added a column and in the header added a button which opens a ContextMenu (pretty much copy-pasted from the docs). Works fine, but this extra column is bothering.

image

Is there a way to colspan the last two columns? Or any other suggestions how to add that context menu to the table header without adding a column?
Yes, it would be much easier to have that context menu button outside the table, but the client likes to have the same way as before.

I think your best bets are either adding the column selector component in the last column’s header (along with the label) or place it outside the Grid and use CSS position relative/absolute to tweak its position so it’s on top of the grid. The former solution is probably the better one, the latter is hacky and prone to breaking unless you pay careful attention to sizing changes.

1 Like

Thanks for your reply.

In the meantime the client agreed to put this in the grid’s context menu. :)