use of com.vaadin.flow.component.virtuallist.VirtualList in project flow-components by vaadin.
the class VirtualListPage method createDataProviderWithStrings.
private void createDataProviderWithStrings() {
VirtualList<String> list = new VirtualList<>();
list.setHeight("100px");
DataProvider<String, ?> dataProvider1 = DataProvider.ofItems("Item 1", "Item 2", "Item 3");
DataProvider<String, ?> dataProvider2 = DataProvider.ofItems("Another item 1", "Another item 2");
DataProvider<String, ?> dataProvider3 = DataProvider.ofItems();
list.setDataProvider(dataProvider1);
NativeButton setProviderWith3Items = new NativeButton("Change dataprovider 1", evt -> list.setDataProvider(dataProvider1));
NativeButton setProviderWith2Items = new NativeButton("Change dataprovider 2", evt -> list.setDataProvider(dataProvider2));
NativeButton setEmptyProvider = new NativeButton("Change dataprovider 3", evt -> list.setDataProvider(dataProvider3));
list.setId("dataprovider-with-strings");
setProviderWith3Items.setId("dataprovider-with-strings-3-items");
setProviderWith2Items.setId("dataprovider-with-strings-2-items");
setEmptyProvider.setId("dataprovider-with-strings-0-items");
add(list, setProviderWith3Items, setProviderWith2Items, setEmptyProvider);
}
use of com.vaadin.flow.component.virtuallist.VirtualList 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);
}
use of com.vaadin.flow.component.virtuallist.VirtualList in project flow-components by vaadin.
the class VirtualListPage method createListWithStrings.
private void createListWithStrings() {
VirtualList<String> list = new VirtualList<>();
list.setHeight("100px");
list.setItems("Item 1", "Item 2", "Item 3");
NativeButton setListWith3Items = new NativeButton("Change list 1", evt -> list.setItems("Item 1", "Item 2", "Item 3"));
NativeButton setListWith2Items = new NativeButton("Change list 2", evt -> list.setItems("Another item 1", "Another item 2"));
NativeButton setEmptyList = new NativeButton("Change list 3", evt -> list.setItems());
list.setId("list-with-strings");
setListWith3Items.setId("list-with-strings-3-items");
setListWith2Items.setId("list-with-strings-2-items");
setEmptyList.setId("list-with-strings-0-items");
add(list, setListWith3Items, setListWith2Items, setEmptyList);
}
use of com.vaadin.flow.component.virtuallist.VirtualList in project flow-components by vaadin.
the class VirtualListViewPage method createStringListWithDataProvider.
private void createStringListWithDataProvider() {
VirtualList<String> list = new VirtualList<>();
list.setHeight("200px");
list.getStyle().set("border", "1px solid lightgray");
DataProvider<String, ?> dataProvider = DataProvider.fromCallbacks(query -> queryStringsFromDatabase(query), query -> countStringsFromDatabase(query));
list.setDataProvider(dataProvider);
list.setId("list-of-strings-with-dataprovider");
add(new Div(new Text("List of books lazy loaded from the database")), list);
}
Aggregations