Search in sources :

Example 71 with Grid

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

the class GridItemRefreshPage method createTemplateGrid.

private void createTemplateGrid() {
    Grid<Bean> grid = new Grid<>();
    grid.setHeight("500px");
    grid.addColumn(Bean::getFirstField).setHeader("First Field");
    grid.addColumn(Bean::getSecondField).setHeader("Second Field");
    grid.addColumn(UPDATE_RENDERER.withProperty("thirdField", bean -> bean.thirdField)).setHeader("mutation");
    List<Bean> items = createItems(1000);
    grid.setItems(items);
    grid.setId("template-grid");
    Div div = new Div();
    div.setText("Template Grid");
    add(div, grid);
    addButtons(grid, items, "template-");
}
Also used : Div(com.vaadin.flow.component.html.Div) Grid(com.vaadin.flow.component.grid.Grid)

Example 72 with Grid

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

the class GridSingleSelectionPage method setDeselectAllowedAndSetItems.

private Grid<String> setDeselectAllowedAndSetItems() {
    Grid<String> grid = new Grid<>();
    GridSingleSelectionModel gssm = (GridSingleSelectionModel) grid.getSelectionModel();
    // Set deselectAllowed to false
    gssm.setDeselectAllowed(false);
    // Set Items for grid
    grid = setItemsGrid(grid, ITEMS_GRID);
    Button text = new Button();
    grid.addSelectionListener(e -> {
        if (e.getFirstSelectedItem().isPresent()) {
            text.setId("item" + e.getFirstSelectedItem().get());
            text.setText("The row " + e.getFirstSelectedItem().get() + " is selected");
            add(text);
        }
    });
    return grid;
}
Also used : GridSingleSelectionModel(com.vaadin.flow.component.grid.GridSingleSelectionModel) Button(com.vaadin.flow.component.button.Button) NativeButton(com.vaadin.flow.component.html.NativeButton) Grid(com.vaadin.flow.component.grid.Grid)

Example 73 with Grid

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

the class OverrideClientValidationPage method createGridSetup.

private void createGridSetup() {
    selectInGrid = new Select<>();
    Grid<String> grid = new Grid<>();
    grid.setItems("test");
    grid.addColumn(new ComponentRenderer<>(item -> selectInGrid, (component, item) -> component));
    add(new H1("Grid select usage"), grid);
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Grid(com.vaadin.flow.component.grid.Grid) Select(com.vaadin.flow.component.select.Select) H1(com.vaadin.flow.component.html.H1) Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) Span(com.vaadin.flow.component.html.Span) Route(com.vaadin.flow.router.Route) Grid(com.vaadin.flow.component.grid.Grid) H1(com.vaadin.flow.component.html.H1)

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