Sort by .setSortProperty("name") in column is not working in grid

Hello Team im using latest vaadin version

Im using callbackdataprovider

public class UserTable extends Grid<Map<String, String>> {

private void makeColumn(){
        Column<Map<String,String>> column = addColumn(TemplateRenderer.<Map<String, String>>of("<a router-link href='[[item.id]]' on-click='handleClick'><vaadin-icon class='verified-link'                                 icon=\"[[item.verified]]\"></vaadin-icon>[[item.link]]</a>")
                    .withProperty("id", this::getId())
                    .withProperty("urllink", map -> map.get(userCode.getLink()))
                    .withProperty("verified", map -> "true".equals(map.get("verified"))?"vaadin:check_circle":"")
                ).setSortable(true).setSortProperty("verified").setAutoWidth(true).setResizable(true);

the column is not getting sorted by the .setSortProperty(“verified”) i dont know why

i have also tried backend sorting
addSortListener(event ->{
String currentSortOrder = getDataCommunicator()
.getBackEndSorting().stream()
.map(querySortOrder → String.format(
“{sort property: %s, direction: %s}”,
querySortOrder.getSorted(),
querySortOrder.getDirection()))
.collect(Collectors.joining(", "));
System.out.println(String.format(
“Current sort order: %s. User-clicked: %s.”,
currentSortOrder, event.isFromClient()));
});

}

but still the column is not getting sorted by the specific property
can anyone help !

Can you show your setItems method with the callbackdataprovider?

If you are using a repository you have to pass the sorting there as well

But generally if I use setSorting(true) then the items are getting sorted but its not getting sorted by property don’t know why

dataProvider = new CallbackDataProvider<>(
q → getListStream(q),
q → getTotalRows(),
m → m.get(ids));
}

then i do setDataProvider(dataprovider);

how does getListStream look like?

The Query object (q variable in your lambda) should contain the sort properties

something like this
List<Map<String, String>> results = new ArrayList<>();
var mylist = userService.getTheUserList();
results.add(mylist);
return results;

Can i use
.setSortOrderProvider(
// Sort according to last name, then first name
direction → Stream.of(
new QuerySortOrder(“lastName”, direction),
new QuerySortOrder(“firstName”, direction)));

But it also not working

Your Backend has to sort the items.

You are passing “q” to the Backend and should handle it accordingly.