I am new to Vaadin and trying to set selected values of Comboboxes in a column of a Grid.
I am doing something like:
personsGrid.setCaption("Persons");
personsGrid.setItems(getEmployeesPersons());
personsGrid.addColumn(EmployeePerson::getTitle).setCaption("Title");
personsGrid.addColumn(EmployeePerson::getFirstName).setCaption("First Name");
personsGrid.addColumn(EmployeePerson::getLastName).setCaption("Last Name");
personsGrid.addColumn(EmployeePerson::getEmail).setCaption("Email");
personsGrid.addComponentColumn(role -> {
ComboBox<String> selectRoles = new ComboBox<>();
selectRoles.setItems(getRoles());
//here I want to set selected item of combobox in a similar way like in the
//other columns above, but I don't know how I can get the corresponding values here.
//It would be something like the following line of code which is not working
selectRoles.setSelectedItem(EmployeePerson::getRole);
return selectRoles;
}).setCaption("LM");
Any idea how this can be achieved? Is there a way to get somehow the current object of the list which is populating the grid in runtime?