use of com.vaadin.flow.data.renderer.Renderer in project flow-components by vaadin.
the class IronListTestPage method createTemplateFromRendererWithPeople.
private void createTemplateFromRendererWithPeople() {
IronList<Person> list = new IronList<>();
list.setHeight("100px");
List<Person> people = createPeople(3);
DataProvider<Person, ?> dataProvider = DataProvider.ofCollection(people);
list.setDataProvider(dataProvider);
list.setRenderer(TemplateRenderer.<Person>of("[[item.name]] - [[item.age]] - [[item.user]]").withProperty("name", Person::getName).withProperty("age", Person::getAge).withProperty("user", person -> person.getName().toLowerCase().replace(" ", "_")));
NativeButton update = new NativeButton("Update item 1", evt -> {
Person item = people.get(0);
item.setName(item.getName() + " Updated");
list.getDataProvider().refreshItem(item);
});
list.setId("template-renderer-with-people");
update.setId("template-renderer-with-people-update-item");
add(list, update);
}
use of com.vaadin.flow.data.renderer.Renderer in project flow-components by vaadin.
the class VirtualListPage method createListWithComponentRendererWithBeansAndPlaceholder.
private void createListWithComponentRendererWithBeansAndPlaceholder() {
VirtualList<Person> list = new VirtualList<>();
list.setHeight("100px");
List<Person> people = createPeople(100);
list.setRenderer(new ComponentRenderer<Div, Person>(person -> {
Div text = new Div(new Text(person.getName()));
text.addClassName("component-rendered");
return text;
}));
list.setItems(people);
list.setId("component-renderer-with-beans");
Person placeholder = new Person();
placeholder.setName("the-placeholder");
list.setPlaceholderItem(placeholder);
add(list);
}
Aggregations