2

I am using a com.vaadin.flow.component.grid.Grid in my Vaadin 14 sample app. I have added an extra header row and introduced a toggle button for changing its visibility.

Unfortunately, this led me deep down to com.vaadin.flow.component.grid.ColumnLayer, which is not visible.

I have also considered dropping the header cell contents and re-adding them. However, this just leaves a full-height row behind. I have also thought about applying some CSS, but could not find a way to, without altering the official source code.

Can anyone help with a more appropriate solution than building my own Grid version (by forking the official implementation)? This feels like pretty common grid functionality to me...

Antonio
  • 47
  • 6
  • Have you check this https://cookbook.vaadin.com/grid-column-toggle – Tatu Lund Oct 28 '21 at 09:51
  • Yes, but that's about column toggling, not rows (column headers). Unless I am missing something? – Antonio Oct 28 '21 at 09:52
  • 2
    There is no API for header row removal yet: https://github.com/vaadin/flow-components/issues/1538 – Tatu Lund Oct 28 '21 at 09:56
  • 2
    We have two tickets, one about removal (what Tatu said) and the other one about hiding in case that's what you are looking for: https://github.com/vaadin/flow-components/issues/1218 – Serhii Kulykov Oct 28 '21 at 15:51
  • Thanks, Serhii! Will hiding as shown in that URL work on the fly? I.e. if setting grid's Id based on a toggle button? I would appreciate an answer, but I will give it a try when I'll return at the office. – Antonio Oct 28 '21 at 18:40

1 Answers1

0

To whom might be interested about this... I have used the dirty workaround mentioned the link shared by Tatu Lund. However, that only works for GridSingleSelectionModel. For GridMultiSelectionModel, the underlying implementation is rather strange. For example, I complemented the GridSingleSelectionModel workaround with setting visibility to false on the Un/Select All checkbox the GridMultiSelectionModel generates. This seems to have a listener on it and automatically hides the checkboxes generated by the GridMultiSelectionModel on each row. Which is similar to GridNoneSelectionModel, so unusable if you need to be able to select items.

Unfortunately, I have trusted that Vaadin 14 should be pretty mature by now, but as I explore it I find myself in the position to rather choose version 8, for instance. It's not the first issue of this kind and, that being said, I am not sure I understand why is Vaadin releasing new major versions every so often, while they don't seem to be able to deliver a comprehensive, stable and reliable option to their adopters. Vaadin 8 is almost 5 years old, and it looks like no later version is even close to it.

Antonio
  • 47
  • 6