grid data list sorting on server

When client side sort is clicked, Its not refreshing order of the grid data list model on server. Is it required to do manually If needed on server or any ready api to get sorted list from grid?

tried below code to do manual sort but didn’t work


grid.addSortListener(e->{
			sortedList=e.getSortOrder();
			grid.sort(sortedList);
		});

Sorting does not update the underlying data. I don’t think there is an API to fetch the grid items in the current order. You can call grid.getDataProvider().fetch, but you have to create a query object with the right sort order and filters.

The code you provided doesn’t seem to work since it is applying the same sort order that has already been applied. What are you trying to achieve?

I don’t think there is an API to fetch the grid items in the current order.

Yes, it is a missing feature: https://github.com/vaadin/flow/issues/4510

Thanks,
I am implementing range row selection in grid. The specific scenario gives problem, when client column is sorted, index order of client and server getting mismatched as server list is not sorted.
So I think need to try to sort server list with custom code to manage it.

In issue linked above one person used the same approach I suggested, calling grid.getDataProvider().fetch https://github.com/vaadin/flow/issues/4510#issuecomment-519650164, in his case to get the number of filtered items. I think it is the best approach until that feature is implemented.

I have inMemory data so I am calling comparator to sort the data for now.

Hi, range row selection sample is created like this: https://vaadin-grid-range-selection.herokuapp.com/

can find example source here
https://github.com/bkasodariya/vaadin-grid-range-selection