use of com.vaadin.flow.data.renderer.LocalDateTimeRenderer in project komunumo-server by komunumo.
the class RegistrationsDialog method configureGrid.
private void configureGrid() {
grid.setSelectionMode(Grid.SelectionMode.NONE);
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
grid.addClassName("registration-dialog");
grid.addColumn(new ComponentRenderer<>(registrationListEntity -> new Anchor("mailto:" + registrationListEntity.email(), registrationListEntity.fullName()))).setHeader("Attendee").setAutoWidth(true).setFlexGrow(0);
grid.addColumn(new LocalDateTimeRenderer<>(RegistrationListEntity::date, FormatterUtil.dateTimeFormatter())).setHeader("Registration date").setAutoWidth(true).setFlexGrow(0);
grid.addColumn(RegistrationListEntity::source).setHeader("Source").setAutoWidth(true).setFlexGrow(0);
if (event.getDate().isBefore(LocalDateTime.now())) {
grid.addColumn(new ComponentRenderer<>(registrationListEntity -> new Icon(registrationListEntity.noShow() ? VaadinIcon.CLOSE_CIRCLE_O : VaadinIcon.CHECK_CIRCLE_O))).setHeader("No show").setTextAlign(ColumnTextAlign.CENTER).setAutoWidth(true).setFlexGrow(0);
}
grid.addColumn(new ComponentRenderer<>(registrationListEntity -> {
final var deregisterButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deregister(registrationListEntity));
deregisterButton.setTitle("Deregister this attendee");
deregisterButton.setEnabled(event.getDate() != null && event.getDate().isAfter(LocalDateTime.now()));
return deregisterButton;
})).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
grid.setWidthFull();
grid.setHeightFull();
}
use of com.vaadin.flow.data.renderer.LocalDateTimeRenderer in project flow-components by vaadin.
the class GridViewUsingRenderersPage method createBasicRenderers.
private void createBasicRenderers() {
Grid<Item> grid = new Grid<>();
grid.setItems(getShoppingCart());
grid.addColumn(Item::getName).setHeader("Name");
// NumberRenderer to render numbers in general
grid.addColumn(new NumberRenderer<>(Item::getPrice, "$ %(,.2f", Locale.US, "$ 0.00")).setHeader("Price");
// LocalDateTimeRenderer for date and time
grid.addColumn(new LocalDateTimeRenderer<>(Item::getPurchaseDate, DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.MEDIUM))).setHeader("Purchase date and time").setFlexGrow(2);
// LocalDateRenderer for dates
grid.addColumn(new LocalDateRenderer<>(Item::getEstimatedDeliveryDate, DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))).setHeader("Estimated delivery date");
// Icons
grid.addColumn(new IconRenderer<>(item -> item.getPrice() > 50 ? new Span("$$$") : new Span("$"), item -> ""));
// NativeButtonRenderer for an easy clickable button,
// without creating a component
grid.addColumn(new NativeButtonRenderer<>("Remove", item -> {
ListDataProvider<Item> dataProvider = (ListDataProvider<Item>) grid.getDataProvider();
dataProvider.getItems().remove(item);
dataProvider.refreshAll();
})).setWidth("100px").setFlexGrow(0);
grid.setId("grid-basic-renderers");
addCard("Using renderers", "Using basic renderers", grid);
}
Aggregations