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='[[]]' on-click='handleClick'><vaadin-icon class='verified-link'                                 icon=\"[[item.verified]]\"></vaadin-icon>[[]]</a>")
                    .withProperty("id", this::getId())
                    .withProperty("urllink", map -> map.get(userCode.getLink()))
                    .withProperty("verified", map -> "true".equals(map.get("verified"))?"vaadin:check_circle":"")

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()
.map(querySortOrder → String.format(
“{sort property: %s, direction: %s}”,
.collect(Collectors.joining(", "));
“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();
return results;

Can i use
// 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.