Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Sorting a tree
Hi, I'm using Vaadin 6.7, and I have a tree of strings which needs to be sorted in a special way. I have created a class that implements ItemSorter, and I add it like this:
HierarchicalContainer beans = new HierarchicalContainer(); Tree subscriberTree = new Tree(); subscriberTree.setImmediate(true); beans = this.generarContainer(subscribers); subscriberTree.setContainerDataSource(beans); subscriberTree.setSelectable(true); [b] beans.setItemSorter(new MySorter());[/b]
But the compare() method in MySorter never gets invoked. Is there something I'm doing wrong?
Dani Pardo: But the compare() method in MySorter never gets invoked. Is there something I'm doing wrong?
are you calling the sort method on your HierarchicalContainer anywhere in your code? You should call the method to explicitly trigger sorting on the container.
Hi Teemu, and thanks, that seems to work now. At least the compare method gets called.
Although I still don't get how to call the sort() method in the container, why do we have to pass the array of propertyIds and another array of booleans? Shouldn't it just sort them all (i.e a method sort with no parameters)?