Vaadin grid sortable(true) doesn't work

addColumn(MyDTO::getName).setHeader("Name").setSortable(true);

getName is a String which implements Comparable. Gui shows the sort buttons, but it doesn’t sort.

Vaadin version 14.4.4.

What am I doing wrong here?

Are you using setSortableColumns by chance somewhere else in your code? This overrides all other sorters.

If not, please post a more complete code example as this should be ok.

Not I’m not using setSortableColumns.

@SpringComponent
@Scope(SCOPE_PROTOTYPE)
public final class ScenarioGrid extends Grid<ScenarioGridDTO> {

	private static final int PAGE_SIZE = 25;

	ScenarioGrid(ScenarioRepository scenarioRepository) {
		super(PAGE_SIZE);
		addThemeVariants(LUMO_NO_BORDER);
		setClassName("scenarioGrid");

		setDataProvider(createDataProvider(null, scenarioRepository));
		setUniqueKeyProvider(ScenarioGridDTO::getUuid);

		addColumn(ScenarioGridDTO::getScenarioName).setHeader("Scenarios").setSortable(true);
		addColumn(ScenarioGridDTO::getScenarioTemplateName).setHeader("Template").setSortable(true);
		addColumn(ScenarioGridDTO::getProfileName).setHeader("Profile").setSortable(true);

		setWidthFull();
	}

The data provider is a normal DataProvider and not a ListDataProvider.

I have different scenario names but when i click on the header to sort, I see that the click is processed but the sorting isn’t done.

I implemented your example and it worked as expected. Only when I added a custom data provider that simply always returns a stream of ScenarioGridDTOs (and calling getLimit/getOffset on the query while ignoring the result) it started to misbehave like you mentioned. So the culprit is definitely in your data provider.