How do I set a custom sorter on vaadin tables?
java, vaadin
Solution
You need to add the ItemSorter to the container used by the table; two container types expose #setItemSorter - IndexedContainer and AbstractBeanContainer. The default container for a Vaadin table is an IndexedContainer.
The following snippet should add an ItemSorter to a table.
Container container = table.getContainerDataSource();
if (container instanceof IndexedContainer) {
((IndexedContainer) container).setItemSorter(itemSorter);
} else if (container instanceof AbstractBeanContainer){
((AbstractBeanContainer) container).setItemSorter(itemSorter);
}
Problem
I want to make my tables ignore letter case when sorting, so I found this link, but I can't figure out where I can actually make the table use the new ItemSorter.