Search in sources :

Example 61 with ComboBox

use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.

the class LazyLoadingPage method createComboBoxWithCustomPageSize.

private void createComboBoxWithCustomPageSize() {
    addTitle("ListDataProvider with custom page size 180");
    ComboBox<String> comboBox = new ComboBox<>(180);
    comboBox.setId("pagesize");
    comboBox.setDataProvider(DataProvider.ofCollection(generateStrings(1000)));
    NativeButton pageSizeButton = new NativeButton("set pagesize 100", e -> comboBox.setPageSize(100));
    pageSizeButton.setId("change-pagesize");
    add(comboBox, pageSizeButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ComboBox(com.vaadin.flow.component.combobox.ComboBox)

Example 62 with ComboBox

use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.

the class LazyLoadingPage method createComboBoxWithCustomPageSizeAndLazyLoading.

private void createComboBoxWithCustomPageSizeAndLazyLoading() {
    addTitle("Callback data provider with custom page size 42");
    ComboBox<String> comboBox = new ComboBox<>(42);
    comboBox.setId("lazy-custom-page-size");
    comboBox.setDataProvider(DataProvider.fromFilteringCallbacks(query -> {
        Stream<String> stream = IntStream.range(0, 500).mapToObj(String::valueOf);
        message.setText(String.valueOf(query.getPageSize()));
        return stream.skip(query.getOffset()).limit(query.getLimit());
    }, query -> 500));
    NativeButton changePageSizeButton = new NativeButton("Change page size", event -> comboBox.setPageSize(41));
    changePageSizeButton.setId("change-page-size-button");
    add(comboBox, changePageSizeButton);
}
Also used : IntStream(java.util.stream.IntStream) ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Div(com.vaadin.flow.component.html.Div) Label(com.vaadin.flow.component.html.Label) NativeButton(com.vaadin.flow.component.html.NativeButton) CallbackDataProvider(com.vaadin.flow.data.provider.CallbackDataProvider) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Collectors(java.util.stream.Collectors) H4(com.vaadin.flow.component.html.H4) Serializable(java.io.Serializable) Route(com.vaadin.flow.router.Route) ComboBoxInATemplate(com.vaadin.flow.component.combobox.test.template.ComboBoxInATemplate) List(java.util.List) Stream(java.util.stream.Stream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataProvider(com.vaadin.flow.data.provider.DataProvider) Element(com.vaadin.flow.dom.Element) Collections(java.util.Collections) Paragraph(com.vaadin.flow.component.html.Paragraph) Span(com.vaadin.flow.component.html.Span) NativeButton(com.vaadin.flow.component.html.NativeButton) ComboBox(com.vaadin.flow.component.combobox.ComboBox) IntStream(java.util.stream.IntStream) Stream(java.util.stream.Stream)

Example 63 with ComboBox

use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.

the class RefreshDataProviderPage method createRefreshAll.

private void createRefreshAll() {
    NativeButton update = new NativeButton("Update");
    update.addClickListener(event -> addNames());
    update.setId("update");
    ComboBox<String> nameSelection = new ComboBox<>("Name");
    nameSelection.setRenderer(new TextRenderer<>());
    nameSelection.setDataProvider(provider);
    add(update, nameSelection);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ComboBox(com.vaadin.flow.component.combobox.ComboBox)

Example 64 with ComboBox

use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.

the class RequiredComboboxPage method requiredComboBoxSetItemsAfter.

private void requiredComboBoxSetItemsAfter() {
    Binder<TestItem> binder = new Binder<>();
    ComboBox<String> comboBox = new ComboBox<>();
    binder.forField(comboBox).asRequired().bind(TestItem::getName, TestItem::setName);
    binder.setBean(new TestItem(0));
    // Set items last:
    comboBox.setItems("foo", "bar");
    add(comboBox);
}
Also used : Binder(com.vaadin.flow.data.binder.Binder) ComboBox(com.vaadin.flow.component.combobox.ComboBox) TestItem(com.vaadin.flow.component.combobox.bean.TestItem)

Example 65 with ComboBox

use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.

the class ClientSideFilterPage method createClientFilterComboBox.

private void createClientFilterComboBox() {
    ComboBox<String> clientFilterComboBox = new ComboBox<>("Browsers");
    clientFilterComboBox.setId(CLIENT_FILTER_COMBO_BOX);
    ComboBoxListDataView<String> clientFilterDataView = clientFilterComboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera", "Apple Safari", "Microsoft Edge");
    Span itemCountSpan = new Span("0");
    itemCountSpan.setId(CLIENT_FILTER_COMBO_BOX_ITEM_COUNT_SPAN_ID);
    this.add(itemCountSpan);
    addListener(itemCountSpan, clientFilterDataView);
    this.add(clientFilterComboBox);
}
Also used : ComboBox(com.vaadin.flow.component.combobox.ComboBox) Span(com.vaadin.flow.component.html.Span)

Aggregations

ComboBox (com.vaadin.flow.component.combobox.ComboBox)69 Div (com.vaadin.flow.component.html.Div)35 Span (com.vaadin.flow.component.html.Span)21 NativeButton (com.vaadin.flow.component.html.NativeButton)20 Route (com.vaadin.flow.router.Route)18 List (java.util.List)16 H2 (com.vaadin.flow.component.html.H2)14 Collectors (java.util.stream.Collectors)14 Label (com.vaadin.flow.component.html.Label)12 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)12 Stream (java.util.stream.Stream)12 Component (com.vaadin.flow.component.Component)10 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)10 ArrayList (java.util.ArrayList)10 Button (com.vaadin.flow.component.button.Button)9 Person (com.vaadin.flow.component.combobox.test.entity.Person)9 PersonService (com.vaadin.flow.component.combobox.test.service.PersonService)9 IntStream (java.util.stream.IntStream)9 ItemFilter (com.vaadin.flow.component.combobox.ComboBox.ItemFilter)8 Paragraph (com.vaadin.flow.component.html.Paragraph)8