Search code examples
javagwtvaadinvaadin7

FilterTable and SQLcontainer in Vaadin


I created simple FilterTable in Vaadin:

    private static final String COL1_PROP = "date";
    private static final String COL2_PROP = "name";
    private static final String COL3_PROP = "status"; 

    //............

    final FilterTable fooTable= new FilterTable();
    fooTable.setImmediate(true);
    fooTable.setSelectable(true);
    fooTable.setWidth("100.0%");
    fooTable.setHeight("100.0%");

    fooTable.setColumnHeader(COL1_PROP, "Date");
    fooTable.setColumnHeader(COL2_PROP, "Name");
    fooTable.setColumnHeader(COL3_PROP, "Status");

    fooTable.setFilterBarVisible(true); //show filters
    fooTable.setFilterFieldVisible(COL1_PROP, false); //hide col1_prop column filter

    fooTable.setColumnCollapsingAllowed(true); // allow collapsing
    fooTable.setColumnCollapsed(COL3_PROP, true); // collapse col3_prop column

    fooTable.setContainerDataSource(container);

    fooTable.setColumnExpandRatio(COL1_PROP, 1.0f);
    fooTable.setColumnExpandRatio(COL2_PROP, 2.0f);

Where my container is a SQLConterner with query like this:

SELECT date, name, status FROM foo

I'm getting a data with no problem, however, i want to hide Statuscolumn completly. What is more i want to hide a Date column filter. As i supposed lines with comments do this things. However they are not. Im getting full 3 columns in table and all of these columns got filter avaiable.

What is wrong?


Solution

  • Move the commented lines below the setContainerDataSource call.