Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Detect Table headers clicked/changed
If the user clicks to sort a Table column, reorders a column, or enables/disables a collapsed column, can this be detected so we can store it on the server as a user preference so we can put it back in the same state the left it?
Hi David,
Sorting of items in a table is done server-side, so you could provide your own container (extended from some other container) and grab the sorting properties whenever the method is called. As for the other cases, they are performed completely client-side and no events are passed to the server; so you're out of luck there :(
You will have to extend the VTable class and send events to the server when a user reorders/enables/disables columns if you need to store the states.
Sorry I can't help more,
/Jonatan
Jonatan Kronqvist: As for the other cases, they are performed completely client-side and no events are passed to the server; so you're out of luck there :(
In fact, the table component does send notifications of these to the server.
For collapsing, see Table.setColumnCollapsed(). Re-ordering of columns is harder to intercept as it happens - it is handled by the private method Table.setColumnOrder(). However, you can ask the table what is the current order with Table.getVisibleColumns().
Jonatan Kronqvist: As for the other cases, they are performed completely client-side and no events are passed to the server; so you're out of luck there :(
I'll have to correct Jonatan a bit: column reordering and visibility changes are sent to server (although always lazily), but I guess no event is ever sent of those changes inside the server side framework, so you have no way of reacting to those events.
You could perhaps query the visible columns and their order every time the user leaves the page/view/whatever, and store that information somewhere.
Edit: Henri beat me to it :)