Vaadin grid sorting

Hello

I’m using Vaadin 8.0.5 full java based and I’ve a grid view where the loaded data is sorted ascending on the first column. My problem is that clicking on the first column header will trigger the sort ascending again which results in no change for the user as the data was already sorted ascending. Clicking again on the header will make the data be sorted descending. Is there a way how I can configure the header to sort the data descending as of the first click?

Kind regards
Tom

Hi Tom,

I’d recommend sorting the column ascending already on the server-side when initialising your Grid: grid.getColumns().findFirst().ifPresent(grid::sort) That’s a safe way to sort the first column if it is available at the time of executing that particular line of code. If you are certain it exists, you can do [font=courier new]
grid.sort(grid.getColumns().get(0))[font=arial]
. This will inform the client-side that the data is sorted by the first column, as well as apply the sorting to the initial data request.

//Teemu
[/font]
[/font]