use of com.vaadin.flow.data.renderer.NativeButtonRenderer in project flow-components by vaadin.
the class GridViewBasicPage method createDisabledGrid.
private void createDisabledGrid() {
Grid<Person> grid = new Grid<>();
List<Person> people = createItems(500);
grid.setItems(people);
grid.addColumn(Person::getFirstName).setHeader("Name");
grid.addColumn(Person::getAge).setHeader("Age");
grid.addColumn(new NativeButtonRenderer<>("Button")).setHeader("Action");
grid.setSelectionMode(SelectionMode.SINGLE);
// The selection and action button won't work, but the scrolling will
grid.setEnabled(false);
NativeButton toggleEnable = new NativeButton("Toggle enable", evt -> grid.setEnabled(!grid.isEnabled()));
toggleEnable.setId("disabled-grid-toggle-enable");
Div div = new Div(toggleEnable);
grid.setId("disabled-grid");
addCard("Disabled grid", grid, div);
}
use of com.vaadin.flow.data.renderer.NativeButtonRenderer in project flow-components by vaadin.
the class ComboBoxPage method createWithButtonRenderer.
private void createWithButtonRenderer() {
ComboBox<String> comboBox = new ComboBox<>();
Label message = new Label("Nothing clicked yet...");
message.setId("button-renderer-message");
comboBox.setRenderer(new NativeButtonRenderer<>(item -> item, item -> message.setText("Button clicked: " + item)));
comboBox.setItems("foo", "bar");
comboBox.setId("button-renderer");
add(comboBox, message);
}
use of com.vaadin.flow.data.renderer.NativeButtonRenderer 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