SQLContainer - Table query

Hi,

Read that TableQuery supports sorting & filtering and that is what i am looking for whereas FreeFormQuery helps us to pass complex query bt sorting & filtering needs to be implemented .

So just trying to work on Tablequery .I hve two questions on the same :

  1. I am trying to sort the table. I have a primary Key (ID) n two other columns Name & Role,

Whn i sort wrt ID, the order of sorting will be ascending / descending. But when i try the same wrt Name Column &

Role Column, its returning me a random sort. Is it possible to sort the Name & Role column in ascending &

descending manner just as the ID column works.?

Below is my code:

SimpleJDBCConnectionPool connPool = new SimpleJDBCConnectionPool();

try {
container = new SQLContainer(new TableQuery(“users”, connPool));
Table table = new Table(“Employee”, container);
container.sort(new Object {“Name”, “Role”}, new boolean
{true, true});
}
catch(SQLException e) {
getMainWindow().showNotification(
“SQLException while processing”,
e.getLocalizedMessage());
e.printStackTrace();
}

  1. The sample examples i have cme across wrt Tablequery loads the complete table .Is there a way to pass the query to pickup certain columns via TableQuery ?

Thanks

I just realized that TableQuery performs Integer Sorting.

Is there a way to do a string based sort in the column???

Are there any other containers which can perfrom sorting & Filtering??

Thanks

Hi,

Sorting in TableQueries adds ORDER BY to the SQL query. Please check that the generated queries actually do work by setting SQLContainer in debug mode (setDebugMode(true)) and test that the queries return correct results.

As for TableQuery always querying all columns, this is the way it has been designed. You can hide certain columns in Table components by calling Table.setVisibleColumns(), for instance. If you want more control over your query, you should use FreeformQuery.

HTH,
/Jonatan

Thanks for the reply.

I tried setting the container to debug mode, but no success :frowning:

The DB is Mysql…I need a container which provides an option to sort.

SQLContainer is providing an option to sort bt not to the columns wit string values .I would need to sort the strings as well in ascending & descending manner just like the ID (integer sorting)

Can anyone suggest.??

Has anyone implemented sorting in FreeFormQuery???

Thanks

Hi…

I went thru Vaadin sampler and found ExampleUtil container can perform sorting .

I am not able to find it in addons…

Is anyone aware abt itz jar???

Thanks

I have no problems with sorting in SQLContainer, see
the address book demo
for an example where sorting works (click the table headers).

The source for the address book demo can be found at
http://dev.vaadin.com/svn/addons/SQLContainer/trunk/demo
. (change ‘/svn/’ to ‘/browser/’ to browse the source code)

Sorting also works in
the simple demo
. The source code for this can be found at the same place as the address book.

HTH,
/Jonatan