I’m working in Vaadin 22.0.14.
I’ve just wanted to test this cool component, and unfortunately I have to confirm (as Leon Breuer reported) that the data in the table does not appear. The table element itself renders in the page but without any rows, even though I do setItems () of course. The table is empty only text in header is visible, but no rows. Im putting a BeanTable with one ComponentColumn.
See my simple test app (I’ve tried to add an ‘my-todo.zip’ attachment, but I don’t know why I can’t see it to attached to this discussion. I can send it by e-mail :).
I just tried the add-on project with Vaadin 22.0.14, and there seems to be no issue with that.
Hi Tatu! Thanks for your quick reply. You do awsome work doing very useful addons for Vaadin :)
Maybe table with ComponentProvider doesn’t work.
This is my simple view (vaadin starter):
@PageTitle("Main")
@Route(value = "")
public class MainView extends HorizontalLayout {
public MainView() {
setSizeFull();
BeanTable<Person> table = new BeanTable<>();
ComponentProvider<Person> componentProvider = item -> createGridRowProvider().apply(item);
table.addComponentColumn("test", componentProvider);
table.setItems(getPersonList());
add(table);
}
private List<Person> getPersonList() {
List<Person> list = Arrays.asList(
new Person(1, "Nicolaus Copernicus", "Lorem Ipsum."),
new Person(2, "Galileo Galilei", "Simply dummy text."),
new Person(3, "Johannes Kepler", "It has survived."),
new Person(4, "Alberto Galilei", "Lellum pollelum."));
return list;
}
private ValueProvider<Person, Component> createGridRowProvider() {
return (item -> {
Div row = new Div();
row.getStyle().set("display", "flex");
row.getStyle().set("flex-flow", "row nowrap");
Div idCol = new Div();
row.add(idCol);
idCol.getStyle().set("display", "flex");
idCol.getStyle().set("flex-flow", "column wrap");
idCol.getStyle().set("width", "5rem");
idCol.getStyle().set("flex-shrink", "0");
idCol.add(new Span("" + item.getId()));
Div namedCol = new Div();
row.add(namedCol);
namedCol.getStyle().set("display", "flex");
namedCol.getStyle().set("flex-flow", "column wrap");
namedCol.getStyle().set("width", "10rem");
namedCol.getStyle().set("flex-shrink", "0");
Span nameField = new Span("" + item.getName());
nameField.getStyle().set("white-space", "normal");
nameField.getStyle().set("overflow", "auto");
namedCol.add(nameField);
Div descrCol = new Div();
row.add(descrCol);
descrCol.getStyle().set("display", "flex");
descrCol.getStyle().set("flex-flow", "column wrap");
descrCol.getStyle().set("min-width", "10rem");
descrCol.getStyle().set("flex-grow", "1");
Span descrField = new Span("" + item.getDescription());
descrField.getStyle().set("white-space", "normal");
descrField.getStyle().set("overflow", "auto");
descrCol.add(descrField);
return row;
});
}
public class Person {
private Integer id;
private String name;
private String description;
public Person(Integer id, String name, String description) {
super();
this.id = id;
this.name = name;
this.description = description;
}
}
I can confirm that your code does not work in my project either. I do not have clear idea why by quick glance.
Ok. It is fixed in version 2.1.1
Now it is working! Component in the header also :)
A very useful component for simple lists with a small amount of data, i.e. in the master-details windows (where some sub-data list is presented). And it is printable (from a browser)! Because Vaadin Grid is not (with data in memory). I will use it for sure :) Thanks Tatu!