use of com.vaadin.flow.component.grid.Grid in project docs by vaadin.
the class DialogResizable method createDialogLayout.
private static VerticalLayout createDialogLayout() {
Grid<Person> grid = new Grid<>(Person.class, false);
grid.addColumn(Person::getFirstName).setHeader("First name");
grid.addColumn(Person::getLastName).setHeader("Last name");
grid.addColumn(Person::getEmail).setHeader("Email");
grid.addColumn(Person::getProfession).setHeader("Profession");
grid.addColumn(Person::getMembership).setHeader("Membership");
List<Person> people = DataService.getPeople();
grid.setItems(people);
VerticalLayout dialogLayout = new VerticalLayout(grid);
dialogLayout.setPadding(false);
dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
dialogLayout.getStyle().set("min-width", "300px").set("max-width", "100%").set("height", "100%");
return dialogLayout;
}
use of com.vaadin.flow.component.grid.Grid in project WebComponentKit by itsoulltd.
the class AbstractJsqlDataSource method prepareGridUI.
@Override
public GridDataSource prepareGridUI(Grid<E> grid) {
super.prepareGridUI(grid);
updateCellFooter(grid);
int length = grid.getColumns().size();
Grid.Column last = grid.getColumns().get(length - 1);
HorizontalLayout buttonCell = new HorizontalLayout(new Button(" < ", previousAction), new Button(" > ", nextAction));
buttonCell.setPadding(false);
buttonCell.setSpacing(true);
buttonCell.setSizeFull();
buttonCell.setAlignItems(FlexComponent.Alignment.CENTER);
last.setFooter(buttonCell);
return this;
}
use of com.vaadin.flow.component.grid.Grid in project aire-components by aire-ux.
the class ModuleGridTest method ensureModuleGridHasCorrectLayout.
@ViewTest
void ensureModuleGridHasCorrectLayout(@Context TestContext context, @Context Instantiator instantiator) {
val grid = instantiator.createComponent(ModuleGrid.class);
val $ = context.downTo(grid);
val columns = $.select(Grid.Column.class);
assertEquals(columns.size(), 5);
}
use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.
the class AuditLogView method createCommunityGrid.
private Grid<AuditLogGridModel> createCommunityGrid() {
Grid<AuditLogGridModel> grid = new DenseGrid<>(AuditLogGridModel.class);
Column<AuditLogGridModel> timestamp = grid.addComponentColumn(model -> {
if (model.data.isEmpty())
return new Div(new Label(model.timestamp.format(dateTimeFormatter)));
Icon icon = grid.isDetailsVisible(model) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
return new Div(icon, new Label(model.timestamp.format(dateTimeFormatter)));
}).setHeader(getTranslation("view.fenix-admin.audit-log.grid.1")).setSortable(true).setComparator(model -> model.timestamp);
grid.addColumn(model -> model.originator).setHeader(getTranslation("view.fenix-admin.audit-log.grid.2")).setSortable(true).setComparator(model -> model.originator);
grid.addColumn(model -> getTranslation("view.fenix-admin.audit-log.operation." + model.operation)).setHeader(getTranslation("view.fenix-admin.audit-log.grid.3")).setSortable(true).setComparator(comparing(model -> model.operation));
grid.addColumn(model -> getTranslation("view.fenix-admin.audit-log.action." + model.action)).setHeader(getTranslation("view.fenix-admin.audit-log.grid.4")).setSortable(true).setComparator(comparing(model -> model.action));
grid.addColumn(model -> model.name).setHeader(getTranslation("view.fenix-admin.audit-log.grid.5")).setSortable(true).setComparator(comparing(model -> model.name));
grid.addColumn(model -> model.id).setHeader(getTranslation("view.fenix-admin.audit-log.grid.6")).setSortable(true).setComparator(comparing(model -> model.id));
grid.sort(ImmutableList.of(new GridSortOrder<>(timestamp, SortDirection.DESCENDING)));
grid.setItemDetailsRenderer(new ComponentRenderer<>(c -> AuditLogDetailsComponentFactory.create(c.data)));
grid.setSelectionMode(Grid.SelectionMode.NONE);
return grid;
}
use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.
the class CommunityAllocationComponent method createCommunityGrid.
private Grid<CommunityAllocationGridModel> createCommunityGrid() {
Grid<CommunityAllocationGridModel> grid = new DenseGrid<>(CommunityAllocationGridModel.class);
grid.addComponentColumn(model -> {
Icon icon = grid.isDetailsVisible(model) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
return new Div(icon, new Text(model.siteName));
}).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.1")).setSortable(true);
grid.addComponentColumn(model -> new RouterLink(model.name, CommunityAllocationFormView.class, model.id)).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.2")).setSortable(true).setComparator(model -> model.name.toLowerCase());
grid.addColumn(model -> model.resourceCreditName).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.3")).setSortable(true);
grid.addColumn(model -> model.resourceTypeName).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.4")).setSortable(true);
grid.addColumn(model -> model.amountWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.5")).setSortable(true).setComparator(comparing(model -> model.amountWithUnit.amount));
grid.addColumn(model -> model.distributedWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.6")).setSortable(true).setComparator(comparing(model -> model.distributedWithUnit.amount));
grid.addColumn(model -> model.remainingWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.7")).setSortable(true).setComparator(comparing(model -> model.remainingWithUnit.amount));
grid.addComponentColumn(model -> new ResourceProgressBar(model.amountWithUnit.amount, model.consumed, 0)).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.8")).setComparator(comparing(model -> model.consumed));
grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.9")).setTextAlign(ColumnTextAlign.END);
grid.setItemDetailsRenderer(new ComponentRenderer<>(model -> AllocationDetailsComponentFactory.create(model.creationTime, model.validFrom, model.validTo)));
return grid;
}
Aggregations