Ordering rows in Grid components
As you can guess, ordering (or sorting) is another task that should be delegated to the backend services when possible. Moreover, it is most likely required when you are implementing pagination (that is, lazy loading using limit
and offset
parameters) in the backend service as well.
The service method should include a parameter that specifies how to perform the ordering. The Grid
component allows users to click on the column headers to activate ordering by that column. These columns that need ordering are passed to the DataProvider
in a Query
object. You can get these by calling the Query.getSortOrders()
method, which returns a List
of QuerySortOrder
objects. You could pass this List
to the service method, but it's always a good idea to avoid coupling the backend services with frontend technologies. QuerySortOrder
is a class included in Vaadin Framework, so you would need to include Vaadin dependencies in your backend services if they are deployed in a separate...