Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Filtering a TreeTable

Chris McGee
7 years ago Mar 04, 2016 6:55pm
Sebastien Libert
7 years ago Mar 07, 2016 12:36pm
Chris McGee
7 years ago Mar 07, 2016 3:56pm
Guttorm Vik
7 years ago Mar 08, 2016 11:20am
Chris McGee
7 years ago Mar 08, 2016 6:55pm
Chris McGee
7 years ago Mar 17, 2016 9:00pm

Okay, so I had a bit of inspiration this afternoon. Since I couldn't figure out any way of changing the fact that SimpleStringFilter only works on a String, I decided to work around this limitation. Reading the API doc for SimpleStringFilter showed me that "values of other types are converted using toString()." How could I get the HorizontalLayout to return a String?

I created a new class that extends HorizontalLayout and overrides .toString() to return the Label's value!

package info.chrismcgee.sky.scheduling.ui.components;

import com.vaadin.ui.CheckBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;

public class TreeNode extends HorizontalLayout {

     * Serialization!
    private static final long serialVersionUID = 232800657274822961L;
    private CheckBox checkbox;
    private Label label;
     * @param checkbox
     * @param label
    public TreeNode(String name, boolean isChecked) {
        checkbox = new CheckBox(null, isChecked);
        label = new Label(name);
    public String toString() {
        // TODO Auto-generated method stub
        return label.getValue();


Seems so simple, now. Of course, my code for it is probably über-sloppy, but at least it works now!

Now I just need to figure out how to have it filter more properly. i.e., to include the parent/child node when filtering. Also to have it not show the checkbox if the logged-in user doesn't have sufficient privileges.