Hello,
I’ve just tried to run the example code from the guides. However, the grid does not show the data… Or, to be more accurate, it is not visible. The data IS present in the DOM tree, but is not visible. I used the “project base” from the starter packs, and replaced the contents of MainView.
https://vaadin.com/start/v10-project-base
https://vaadin.com/docs/v10/flow/binding-data/tutorial-flow-data-provider.html
MainView:
@HtmlImport("styles/shared-styles.html")
@Route("pg")
public class MainView extends VerticalLayout {
public MainView() {
ComboBox<Status> comboBox = new ComboBox<>();
comboBox.setItemLabelGenerator(Status::getLabel);
Grid<Person> grid = new Grid<>(Person.class);
grid.addColumn(Person::getName).setHeader("Name");
grid.addColumn(person -> Integer.toString(person.getYearOfBirth()))
.setHeader("Year of birth");
// Sets items as a collection
comboBox.setItems(EnumSet.allOf(Status.class));
// Sets items using varargs
grid.setItems(
new Person("George Washington", 1732),
new Person("John Adams", 1735),
new Person("Thomas Jefferson", 1743),
new Person("James Madison", 1751)
);
add(comboBox, grid);
setClassName("main-layout");
}
}
Person:
public class Person {
private String name;
private Status status;
private int yearOfBirth;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public int getYearOfBirth() {
return yearOfBirth;
}
public void setYearOfBirth(int yearOfBirth) {
this.yearOfBirth = yearOfBirth;
}
public Person(String name, int yob) {
this.name = name;
this.yearOfBirth = yob;
}
}
shared-styles is nothing more than…
<custom-style>
<!-- This is where your App's styling should go. You can use .css files too. -->
<style>
.main-layout {
padding: 20px;
}
</style>
</custom-style>
Any idea for a solution? [Screenshot]
(https://i.imgur.com/NGdROEp.png)