Hi Team,
I’m trying to add a sortableColumn. But the columns are not getting sorted at all.
Below is my code:
List<Student> studentList = getDataFromBackend();
TwinColGrid<Student> studentTwinColGrp = new TwinColGrid<Student>()
.addSortableColumn(Student::getName, Comparator.comparing(Student::getName), "Student Name")
.withoutAddAllButton();
studentTwinColGrp.setItems(studentList);
Student Class looks like below:
public class Student implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
.............
// getters-setters
.............
}
I’m using 2.0.3 version of twincolgrid
<dependency>
<groupId>com.flowingcode.vaadin.addons</groupId>
<artifactId>twincolgrid</artifactId>
<version>2.0.3</version>
</dependency>
Is there anyway I can make the columns sortable?
Screenshot attached for reference.
Further efforts:
tried with Comparator.comparing(s → s.getName()) - didn’t work
At the same time I’ve tried to check if ArrayList is actually getting sorted, I’ve tried
Collections.sort(studentList, Comparator.comparing(Student::getName));
The above method actually sorts the list, so no problem in comparator or class definition,