I’m trying to use Vaadin 8 (8.1.5) framework as I have used 7 before. I’ve created my project in the same way that I did with the previous version (using maven archetype in Eclipse - vaadin-archetype-application-example). But now the grid sorting is not working properly (even the ProductGrid class provided by the CRUD example). Can you help me please?
Follow the code:
import com.project.testvaadin8.samples.backend.data.Account;
import com.vaadin.ui.Grid;
public class SimpleGrid extends Grid<Account> {
public SimpleGrid() {
setSizeFull();
addColumn(Account::getAccount).setCaption("Account");
addColumn(Account::getBank).setCaption("Bank");
addColumn(Account::getCurrency).setCaption("Currency");
//setSortOrder(GridSortOrder.desc(getColumn("account")));
}
By default Grid sorts by the toString() presentation of your property. If this does not provide desired result (which is often the case with dates etc.), you need to set custom comparator wíth setSortComparator(…) method of the ListDataProvider.