Search in sources :

Example 61 with Grid

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

the class GridWithTemplatePage method createStandaloneGridWithTemplatesInTheHeader.

private void createStandaloneGridWithTemplatesInTheHeader() {
    Grid<String> grid = new Grid<>();
    setCommonGridFeatures(grid, "standalone-template-in-header");
    grid.addColumn(value -> value).setHeader(getTestTemplate("header", grid.getId().get())).setFooter(getTestTemplate("footer", grid.getId().get()));
    add(new H3("Grid with templates in the header and footer"), grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) H3(com.vaadin.flow.component.html.H3)

Example 62 with Grid

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

the class ContextMenuGridPage method gridInATemplateWithContextMenu.

private void gridInATemplateWithContextMenu() {
    GridInATemplate template = new GridInATemplate();
    Grid<String> gridInATemplate = template.getGrid();
    gridInATemplate.addColumn(s -> s).setHeader("Item");
    gridInATemplate.setItems(IntStream.range(0, 26).mapToObj(i -> "Item " + i));
    GridContextMenu<String> contextMenu = gridInATemplate.addContextMenu();
    contextMenu.addItem("Show name of context menu target item", e -> message.setText(e.getItem().orElse(NO_TARGET_ITEM)));
    add(template);
}
Also used : IntStream(java.util.stream.IntStream) Person(com.vaadin.flow.data.bean.Person) Grid(com.vaadin.flow.component.grid.Grid) Anchor(com.vaadin.flow.component.html.Anchor) GridInATemplate(com.vaadin.flow.component.grid.it.GridInATemplate) H1(com.vaadin.flow.component.html.H1) Div(com.vaadin.flow.component.html.Div) Label(com.vaadin.flow.component.html.Label) NativeButton(com.vaadin.flow.component.html.NativeButton) Hr(com.vaadin.flow.component.html.Hr) Route(com.vaadin.flow.router.Route) GridInATemplate(com.vaadin.flow.component.grid.it.GridInATemplate)

Example 63 with Grid

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

the class GridMultiSelectionColumnPage method createBasicGridFromMultiToSingleBeforeAttached.

private void createBasicGridFromMultiToSingleBeforeAttached() {
    Grid<String> grid = new Grid<>();
    grid.setItems(IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString));
    setUp(grid);
    grid.setId("in-testing-multi-selection-mode-grid-single");
    add(new H2("in-testing-multi-selection-mode-grid-single"), grid);
    grid.setSelectionMode(SelectionMode.MULTI);
    grid.setSelectionMode(SelectionMode.SINGLE);
    add(grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) H2(com.vaadin.flow.component.html.H2)

Example 64 with Grid

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

the class GridMultiSelectionColumnPage method createDefinedItemCountLazyGrid.

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

Example 65 with Grid

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

the class GridMultiSelectionColumnPage method createBasicGridMultiOneRowDeSelected.

private void createBasicGridMultiOneRowDeSelected() {
    Grid<String> grid = new Grid<>();
    grid.setId(MULTI_SELECT_GRID_ONE_NOT_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("1");
    NativeButton selectRow0Button = new NativeButton("Select Row 0");
    selectRow0Button.setId("selectRow0");
    selectRow0Button.addClickListener(event -> {
        grid.getSelectionModel().select("0");
    });
    add(new H2("Grid with two rows only one row selected"), grid, selectRow0Button);
}
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)

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