use of com.vaadin.flow.data.renderer.IconRenderer in project flow-components by vaadin.
the class GridColumnOrderTest method init.
@Before
public void init() {
grid = new Grid<>();
firstColumn = grid.addColumn(str -> str).setKey("firstColumn");
secondColumn = grid.addColumn(str -> str).setKey("secondColumn");
thirdColumn = grid.addColumn(str -> str).setKey("thirdColumn");
IconRenderer<String> renderer = new IconRenderer<>(generator -> new Label(":D"));
fourthColumn = grid.addColumn(renderer).setKey("fourthColumn");
}
use of com.vaadin.flow.data.renderer.IconRenderer in project flow-components by vaadin.
the class RadioButtonGroupDemoPage method addItemIconGenerator.
private void addItemIconGenerator() {
RadioButtonGroup<Person> group = new RadioButtonGroup<>();
group.setItems(new Person(1, "Joe"), new Person(2, "John"), new Person(3, "Bill"));
group.setRenderer(new IconRenderer<>(item -> {
Image image = new Image("https://vaadin.com/images/vaadin-logo.svg", "");
image.getStyle().set("height", "15px");
image.getStyle().set("float", "left");
image.getStyle().set("marginRight", "5px");
image.getStyle().set("marginTop", "2px");
return image;
}, Person::getName));
group.setId("button-group-icon-generator");
addCard("Radio button group with icon generator", group);
}
use of com.vaadin.flow.data.renderer.IconRenderer 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