Custom collapsible column button

Hello,
I have a table which uses collapsible columns. I am not a huge fan of the tiny button for selecting visible rows. I know you can change the css style for the button but I am more interested to know if I can create a Vaadin button (outside of the table) that would provide the same functionality. Has anyone done this or is it even possible?

Any ideas?

Thanks!

Hi,

I think it should be possible to make your own custom button for changing that. I would start by extending CssLayout and placing a Table and a Menubar inside it.

The MenuBar would be the button, and the menu items would trigger the setVisibleColumns method for the Table. You can call setSelected for the menubar items. You can then style the root item of the menubar to look like a button, which I guess will be the hardest part here (but it’s just regular CSS, and you could possibly call setPrimaryStyleName for the MenuBar to make it easier.

Then you could use CSS to position the button/menubar/dropdown on top of the table where you want it.

A rough starting point, but I hope you got some ideas to consider.