Hi Team, I'm trying to add a sortableColumn. But the columns are not getti

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,

Hi Mohan!

We’ve created [this issue]
(https://github.com/FlowingCode/TwinColGridAddon/issues/20) to work on this.

We’ll let you know when it’s done.

Regards.

Hi Mohan.

We revised this issue and confirmed that the sorting function works as expected. The elements of the list are not sorted until the user clicks on the sorting arrows next to the column header (as can be seen on the attached gif).
As a workaround, you could sort the list before setting it to the TwinColGrid.
Maybe an extra method to sort the grids programatically is needed.

18446808.gif