How to set up custom sorter on vaadin tables?

I want my tables to ignore the case of the letter when sorting, so I found this link, but I cannot figure out where I can actually make the table use the new ItemSorter.

+3
source share
1 answer

You need to add ItemSorter to the container used by the table; two types of containers expose #setItemSorter - IndexedContainer and AbstractBeanContainer. The default container for a Vaadin table is an IndexedContainer.

The following snippet should add an ItemCorter to the table.

Container container = table.getContainerDataSource();      
  if (container instanceof IndexedContainer) {
    ((IndexedContainer) container).setItemSorter(itemSorter);
  } else if (container instanceof AbstractBeanContainer){
    ((AbstractBeanContainer) container).setItemSorter(itemSorter);
  }
+4
source

All Articles