Search in sources :

Example 26 with Person

use of com.vaadin.flow.data.bean.Person in project flow-components by vaadin.

the class GridViewStylingPage method createStyling.

private void createStyling() {
    String instructions = "<p>In order to inject styles into Grid cells, " + "create a style-module like in the snippet below, " + "put it into an html-file in your resources folder, " + "and import it with <code>@HtmlImport</code>. " + "After this you can apply the CSS classes " + "(<code>subscriber</code> and <code>minor</code> in this case) " + "into grid rows and cells as shown in the next example.</p>";
    addCard("Styling", "Styling Grid Cells", new Html(instructions));
    Grid<Person> grid = new Grid<>();
    grid.setItems(getItems());
    grid.setSelectionMode(SelectionMode.NONE);
    grid.addColumn(Person::getFirstName).setHeader("Name");
    Column<Person> ageColumn = grid.addColumn(Person::getAge).setHeader("Age");
    grid.addColumn(person -> person.isSubscriber() ? "Yes" : "").setHeader("Subscriber");
    grid.setClassNameGenerator(person -> person.isSubscriber() ? "subscriber" : "");
    ageColumn.setClassNameGenerator(person -> person.getAge() < 18 ? "minor" : "");
    grid.setId("class-name-generator");
    addCard("Styling", "Generating CSS Class Names for Cells", grid);
}
Also used : Column(com.vaadin.flow.component.grid.Grid.Column) Person(com.vaadin.flow.data.bean.Person) Grid(com.vaadin.flow.component.grid.Grid) Html(com.vaadin.flow.component.Html) SelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode) Route(com.vaadin.flow.router.Route) Grid(com.vaadin.flow.component.grid.Grid) Html(com.vaadin.flow.component.Html) Person(com.vaadin.flow.data.bean.Person)

Example 27 with Person

use of com.vaadin.flow.data.bean.Person in project flow-components by vaadin.

the class HiddenColumnPage method createPerson.

private Person createPerson(String name, String email) {
    Person person = new Person();
    person.setFirstName(name);
    person.setEmail(email);
    return person;
}
Also used : Person(com.vaadin.flow.data.bean.Person)

Example 28 with Person

use of com.vaadin.flow.data.bean.Person in project flow-components by vaadin.

the class GridEditorRefreshPage method createAnotherPerson.

private Person createAnotherPerson() {
    Person person = new Person();
    person.setFirstName("bar");
    person.setEmail("baz@gmail.com");
    return person;
}
Also used : Person(com.vaadin.flow.data.bean.Person)

Aggregations

Person (com.vaadin.flow.data.bean.Person)28 Grid (com.vaadin.flow.component.grid.Grid)21 Div (com.vaadin.flow.component.html.Div)13 NativeButton (com.vaadin.flow.component.html.NativeButton)12 Route (com.vaadin.flow.router.Route)12 List (java.util.List)8 Column (com.vaadin.flow.component.grid.Grid.Column)7 ArrayList (java.util.ArrayList)7 TextField (com.vaadin.flow.component.textfield.TextField)6 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)5 Button (com.vaadin.flow.component.button.Button)4 SelectionMode (com.vaadin.flow.component.grid.Grid.SelectionMode)4 Editor (com.vaadin.flow.component.grid.editor.Editor)4 Span (com.vaadin.flow.component.html.Span)4 Binder (com.vaadin.flow.data.binder.Binder)4 EmailValidator (com.vaadin.flow.data.validator.EmailValidator)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 WeakHashMap (java.util.WeakHashMap)4 HeaderRow (com.vaadin.flow.component.grid.HeaderRow)3