use of com.vaadin.flow.component.ironlist.IronList in project flow-components by vaadin.
the class IronListTestPage method createTemplateFromValueProviderWithPeople.
private void createTemplateFromValueProviderWithPeople() {
IronList<Person> list = new IronList<>();
list.setHeight("100px");
DataProvider<Person, ?> dataProvider1 = DataProvider.ofCollection(createPeople(3));
DataProvider<Person, ?> dataProvider2 = DataProvider.ofCollection(createPeople(2));
DataProvider<Person, ?> dataProvider3 = DataProvider.ofCollection(createPeople(0));
list.setDataProvider(dataProvider1);
list.setRenderer(Person::getName);
NativeButton setProviderWith3Items = new NativeButton("Change dataprovider 1", evt -> {
list.setRenderer(Person::getName);
list.setDataProvider(dataProvider1);
});
NativeButton setProviderWith2Items = new NativeButton("Change dataprovider 2", evt -> {
list.setDataProvider(dataProvider2);
list.setRenderer(person -> String.valueOf(person.getAge()));
});
NativeButton setEmptyProvider = new NativeButton("Change dataprovider 3", evt -> list.setDataProvider(dataProvider3));
list.setId("dataprovider-with-people");
setProviderWith3Items.setId("dataprovider-with-people-3-items");
setProviderWith2Items.setId("dataprovider-with-people-2-items");
setEmptyProvider.setId("dataprovider-with-people-0-items");
add(list, setProviderWith3Items, setProviderWith2Items, setEmptyProvider);
}
use of com.vaadin.flow.component.ironlist.IronList in project flow-components by vaadin.
the class IronListTestPage method createListWithStrings.
private void createListWithStrings() {
IronList<String> list = new IronList<>();
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.ironlist.IronList in project flow-components by vaadin.
the class IronListTestPage method createListWithComponentRenderer.
private void createListWithComponentRenderer() {
IronList<String> list = new IronList<>();
list.setHeight("100px");
List<String> items = IntStream.range(1, 101).mapToObj(i -> "Item " + i).collect(Collectors.toList());
list.setRenderer(new ComponentRenderer<>(item -> {
Label label = new Label(item);
label.addClassName("component-rendered");
return label;
}));
list.setItems(items);
list.setId("component-renderer");
add(list);
}
use of com.vaadin.flow.component.ironlist.IronList in project flow-components by vaadin.
the class IronListTestPage method createListInsideFlexContainer.
private void createListInsideFlexContainer() {
IronList<String> list = new IronList<>();
list.setId("list-inside-flex-container");
list.setItems("Item 1", "Item 2", "Item 3");
Div flexContainer = new Div(list);
flexContainer.getStyle().set("display", "flex");
NativeButton setFlexDirectionColumn = new NativeButton("Set 'flex-direction: column'", e -> flexContainer.getStyle().set("flex-direction", "column"));
setFlexDirectionColumn.setId("set-flex-direction-column");
add(flexContainer, setFlexDirectionColumn);
}
use of com.vaadin.flow.component.ironlist.IronList in project flow-components by vaadin.
the class IronListView method createStringListWithDataProvider.
private void createStringListWithDataProvider() {
IronList<String> list = new IronList<>();
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");
addCard("List of strings with DataProvider", new Label("List of books lazy loaded from the database"), list);
}
Aggregations