Table sort by column / container.sortable


I’m trying to override some functions of a table/IndexedContainer to achieve the specifications of my project.

The problem I have for the moment is with sorting. If I understand correctly, the table sorts the fields by saying to the container that it should sort it’s field, and then the table reloads the content.

As I have lazy loading on my container, this will only sort the elements that are buffered in the container, resulting that the data will be shown in their original order when you move outside the buffer.

What I would now need is to catch the order that the users wants them in, when they click on the headers. This way I could load the values in sorted order into my container manually. Is there a easy way to ask for these?

I noticed that Container.Sortable implements sort(Object propertyId, boolean
ascending) which does the ordering. Why are these arrays instead of single properties? Do they store these somewhere where they can be accessed, or do I have to override the sorting function to pic them up?

Your container should implement (or override) Container.Sortable and do whatever is needed to sort your container - you’ll probably want to use whatever the backend you’re using provides (e.g sql order by).

The arguments to sort() are arrays of propertyIds, so that you can sort by multiple properties (i.e columns). For instance, if your container uses a SQL database, you could just do a ORDER BY (order by lastname,firstname)

Best Regards,


I resolved it in my first version by just overriding the sort(){propertyId,ascending
} -function and taking the last properties out of the arrays → forwarding these to the database. I can improve this now when i know what the arrays contain in their full extent.