SQLContainer - missing filter

Hi,

I have problem with filtering data in table. I don’t understand why it doesn’t sort.

I’ve put on panel NativeSelect + Table

I retrieve data from db via SQLContainer, code:

private Table table;
private NativeSelect nsFloor;
private SQLContainer containerView = null;
...

private Container initContainerView() {
...
String sQuery = "SELECT t0.* FROM dbo.view t0;";
FreeformQuery query = new FreeformQuery(sQuery, connectionPool, new String[] { "col1" });
containerView = new SQLContainer(query);
...
return containerView;
}

on Gui:

tableView = new Table();
tableView.setSelectable(true);
tableView.setContainerDataSource(initContainerView());

nsFloor = new NativeSelect("Select floor");
nsFloor.addItem(-2);
nsFloor.addItem(-1);
nsFloor.addItem(0);
nsFloor.setItemCaption(-2, "Floor -2");
nsFloor.setItemCaption(-1, "Floor -1");
nsFloor.setItemCaption(0, "Floor 0");

//on Button I have action:

if (nsFloor.getValue() != null) {
  containerView.removeAllContainerFilters();
  containerView.addContainerFilter("rentFloor", nsFloor.getValue().toString(), false, true);
}

When I select floor -2 it should filter data on table but It doesn’t filter data. It works on table with TableQuery but I cannot use it.

Where did I mistake? Can anyone give an ideas?
DB: is MSSQL Server.

Best regards,
Paul

Hi Paul,

You can’t use addContainerFilter(filtering) or sorting with FreeformQuery. You can filter table using i.e. TableQuery or by providing FreeformQueryDelegate or FreeformStatementDelegate implementation.

https://vaadin.com/book/-/page/sqlcontainer.freeform.html

here You have an example of implementing FreeformStatementDelegate
http://dev.vaadin.com/svn/addons/SQLContainer/branches/new-filter-api/demo/src/com/vaadin/addon/sqlcontainer/demo/DemoFreeformQueryDelegate.java

I hope that this will help You.