Search in sources :

Example 66 with Grid

use of com.vaadin.flow.component.grid.Grid in project flow-components by vaadin.

the class GridMultiSelectionColumnPage method createBasicGridMultiAllRowsSelected.

private void createBasicGridMultiAllRowsSelected() {
    Grid<String> grid = new Grid<>();
    grid.setId(MULTI_SELECT_GRID_ALL_SELECTED_GRID_ID);
    grid.setItems(IntStream.range(0, 2).mapToObj(Integer::toString));
    grid.addColumn(i -> i).setHeader("text");
    grid.addColumn(i -> String.valueOf(i.length())).setHeader("length");
    grid.setSelectionMode(Grid.SelectionMode.MULTI);
    grid.getSelectionModel().select("0");
    grid.getSelectionModel().select("1");
    NativeButton deSelectRow0Button = new NativeButton("DeSelect Row 0");
    deSelectRow0Button.setId("deSelectRow0");
    deSelectRow0Button.addClickListener(event -> {
        grid.getSelectionModel().deselect("0");
    });
    add(new H2("Small grid with two rows all selected"), grid, deSelectRow0Button);
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) Grid(com.vaadin.flow.component.grid.Grid) Query(com.vaadin.flow.data.provider.Query) Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) CallbackDataProvider(com.vaadin.flow.data.provider.CallbackDataProvider) SelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode) H2(com.vaadin.flow.component.html.H2) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) List(java.util.List) Stream(java.util.stream.Stream) NativeButton(com.vaadin.flow.component.html.NativeButton) Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Example 67 with Grid

use of com.vaadin.flow.component.grid.Grid in project flow-components by vaadin.

the class GridMultiSelectionColumnPage method setAutoWidthIsTrueOfSelectionColumn.

private void setAutoWidthIsTrueOfSelectionColumn() {
    Grid<String> grid = new Grid<>();
    grid.setItems(IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString));
    setUp(grid);
    grid.setId("set-auto-width-true");
    add(new H2("In-set-auto-width-true"), grid);
    grid.setSelectionMode(SelectionMode.MULTI);
    add(grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Example 68 with Grid

use of com.vaadin.flow.component.grid.Grid in project flow-components by vaadin.

the class GridMultiSelectionColumnPage method createUnknownItemCountLazyGrid.

private void createUnknownItemCountLazyGrid() {
    Grid<String> unknownItemCountLazyGrid = new Grid<>();
    unknownItemCountLazyGrid.setItems(query -> IntStream.range(query.getOffset(), query.getOffset() + query.getLimit()).mapToObj(Integer::toString));
    setUp(unknownItemCountLazyGrid);
    unknownItemCountLazyGrid.setId(UNKNOWN_ITEM_COUNT_LAZY_GRID_ID);
    add(new H2("Unknown Item Count Lazy grid"), unknownItemCountLazyGrid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Example 69 with Grid

use of com.vaadin.flow.component.grid.Grid in project flow-components by vaadin.

the class GridMultiSelectionColumnPage method createGridWithSwappedDataProvider.

private void createGridWithSwappedDataProvider() {
    Grid<String> grid = new Grid<>();
    setUp(grid);
    grid.setItems(Arrays.asList("Item 1", "Item 2", "Item 3"));
    grid.setItems(new CallbackDataProvider<>(this::fetch, this::count));
    grid.setId("swapped-grid");
    NativeButton inMemory = new NativeButton("Set in-memory DataProvider", evt -> grid.setItems(Arrays.asList("Item 1", "Item 2", "Item 3")));
    inMemory.setId("set-in-memory-button");
    NativeButton backEnd = new NativeButton("Set backend DataProvider", evt -> grid.setItems(new CallbackDataProvider<>(this::fetch, this::count)));
    backEnd.setId("set-backend-button");
    add(new H2("Swapped grid"), grid, inMemory, backEnd);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2) CallbackDataProvider(com.vaadin.flow.data.provider.CallbackDataProvider)

Example 70 with Grid

use of com.vaadin.flow.component.grid.Grid in project flow-components by vaadin.

the class GridFilteringPage method createLazyLoadingAndFilterableGrid.

private void createLazyLoadingAndFilterableGrid() {
    Grid<String> grid = new Grid<>();
    grid.addColumn(ValueProvider.identity()).setHeader("Items");
    final List<String> items = IntStream.range(0, 1000).mapToObj(item -> "Item " + item).collect(Collectors.toList());
    TextField filterField = new TextField("Search Item");
    filterField.setId(GRID_FILTER_ID);
    filterField.addValueChangeListener(event -> grid.getGenericDataView().refreshAll());
    grid.setItems(query -> {
        String searchTerm = filterField.getValue();
        return items.stream().filter(item -> searchTerm.isEmpty() || item.contains(searchTerm)).skip(Math.min(items.size(), query.getOffset())).limit(query.getLimit());
    });
    grid.setId(LAZY_FILTERABLE_GRID_ID);
    add(filterField, grid);
}
Also used : IntStream(java.util.stream.IntStream) Grid(com.vaadin.flow.component.grid.Grid) ValueProvider(com.vaadin.flow.function.ValueProvider) Collection(java.util.Collection) Set(java.util.Set) Div(com.vaadin.flow.component.html.Div) CallbackDataProvider(com.vaadin.flow.data.provider.CallbackDataProvider) Collectors(java.util.stream.Collectors) Route(com.vaadin.flow.router.Route) ConfigurableFilterDataProvider(com.vaadin.flow.data.provider.ConfigurableFilterDataProvider) List(java.util.List) Stream(java.util.stream.Stream) DataProvider(com.vaadin.flow.data.provider.DataProvider) Optional(java.util.Optional) Collections(java.util.Collections) TextField(com.vaadin.flow.component.textfield.TextField) LinkedHashSet(java.util.LinkedHashSet) Grid(com.vaadin.flow.component.grid.Grid) TextField(com.vaadin.flow.component.textfield.TextField)

Aggregations

Grid (com.vaadin.flow.component.grid.Grid)73 Route (com.vaadin.flow.router.Route)41 Div (com.vaadin.flow.component.html.Div)38 List (java.util.List)26 NativeButton (com.vaadin.flow.component.html.NativeButton)22 Person (com.vaadin.flow.data.bean.Person)22 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)21 H2 (com.vaadin.flow.component.html.H2)17 Collections (java.util.Collections)16 Button (com.vaadin.flow.component.button.Button)15 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)14 ArrayList (java.util.ArrayList)13 Collectors (java.util.stream.Collectors)13 Component (com.vaadin.flow.component.Component)12 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)12 Column (com.vaadin.flow.component.grid.Grid.Column)12 Label (com.vaadin.flow.component.html.Label)12 Span (com.vaadin.flow.component.html.Span)11 TextField (com.vaadin.flow.component.textfield.TextField)10 DenseGrid (io.imunity.furms.ui.components.DenseGrid)10