How Grid sorting works?

I’m using a third party library for get the SQL result set. I pass the offset and limit from the Query like

grid.setItems(query -> DataService.findAll(query.getOffset(),query.getLimit());

The problem here is, the sorting is not working. It still gets the same resultset everytime. I tried clicking different columns but it is getting same data again and again. Not sure what I’m missing. Please let me know what mistake I’m doing and why the sorting is not working.

Looks like you are using lazy loading - there you have to implement sorting yourself

The Query object contains the sort orders

may I’ve some examples or link ? I thought the sorting handled by default when someone clicks the column header

how do I know which column is clicked ?

Our official docs seem to be hiding the actual examples into SpringDataHelpers method. I re-wrote that part so that it actually contains some usable code examples: Improving lazy data binding docs by mstahv · Pull Request #2062 · vaadin/docs · GitHub


Based on your experience, what do you suggest in most of the cases? sorting enabled ? All column sortable or only few ? Do you see any bottlenecks ?

“it depends” - consider you are the user of your app: what do you wanna sort while using the app? Once you have those columns, think about the technical problems each column would produce. Like for example: can the Backend sort by it? Is it s frontend only column? Would the sorting result in really slow behavior and so on