Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with sorting #20

Closed
mlopezFC opened this issue Sep 16, 2020 · 1 comment
Closed

Problem with sorting #20

mlopezFC opened this issue Sep 16, 2020 · 1 comment

Comments

@mlopezFC
Copy link
Member

In a thread from Vaadin Directory, Mohan wrote:

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,

@javier-godoy javier-godoy added this to Inbox (needs triage) in Flowing Code Addons (legacy) via automation Sep 17, 2020
@javier-godoy javier-godoy moved this from Inbox (needs triage) to In Progress in Flowing Code Addons (legacy) Sep 30, 2020
@ngonzalezpazFC
Copy link
Contributor

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, the list could be sorted before setting it to the TwinColGrid. Maybe an extra method to sort the grids programatically is needed. (to be implemented in #31 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

3 participants