I’m using a Vaadin Grid with server-side pagination and adding a custom comparator so that the value "ALL" always appears first when sorting ascending, and last when sorting descending.
.setComparator((j1, j2) → {
String c1 = j1.getCustomer();
String c2 = j2.getCustomer();
if (“ALL”.equalsIgnoreCase(c1))
return -1;
if (“ALL”.equalsIgnoreCase(c2))
return 1;
if (c1 == null && c2 == null) return 0;
if (c1 == null) return 1;
if (c2 == null) return -1;
return c1.compareToIgnoreCase(c2);
})
There seems to be a conflict between the server-side sorting and the UI comparator.
For example, the backend fetch might return the first page with numeric customers first, followed by those starting with “A” — but I should actually be getting the "ALL" rows first.
Has anyone run into this kind of Vaadin server/UI sorting mismatch before? How did you handle custom ordering like this when using server-side pagination?
I just want “ALL” to show up first for ascending order, and “ALL” should show last at descending order