Vaadin 8 Grid inline editor

I have class

public class Person implements Serializable {
   private String name;
   private Date birthDay;
   private int years;

   public gridRecord (String name, Date birthDay, int years){
     this.name = name;
     this.birthDay = birthDay;
     this. years = years;
   }
  
  public int getYears() { return years; }
  public void setYears(int years) { this.years = years; }
  public Date getBirthDay () { return birthDay; }
  public void setBirthDay(Date day) { this.birthDay = day; }
  public String getName () { return name; }
  public void setName(String name) { this.name = name; }
}

So, I try make grid with in row editors:

DateField dateField   = new DateField();
TextField yearsField  = new TextField();
TextField nameField   = new TextField();

Grid<Person> grid = new Grid<>();    
grid.setSelectionMode(SelectionMode.SINGLE);
grid.addColumn(Person::getBirthDay, new DateRenderer()).setCaption("Date")
   .setEditorComponent(dateField, Person::setBirthDay);  <---- here compile error
grid.addColumn(Person::getYears, new TextRenderer()).setCaption("Years")
  .setEditorComponent(yearsField, Person::setYears);     <---- here compile error
grid.addColumn(Person::getName, new TextRenderer())
   .setEditorComponent(nameField, Person::setName);      <---- here no error    

The errors for field “Date” is "The method setEditorComponent(C, Setter<Person,Date>) in the type Grid.Column<Person,Date> is not applicable for the arguments (DateField, Setter<Person,Date>) , same error for field “Years”

The question is: How make in row editor for types other than string (ex. for date, integer)?

DateField is a field for LocalDate not Date that’s why you have this error. Perhaps you can change your model.

For number (or integer), you can setEditorBinding instead of setEditorComponent:
Here an example for Boolean (from https://vaadin.com/docs/v8/framework/components/components-grid.html )

Binder<Todo> binder = grid.getEditor().getBinder();

Binding<Todo, Boolean> doneBinding = binder.bind(
doneField, Todo::isDone, Todo::setDone);

Column<Todo, String> column = grid.addColumn(
todo -> String.valueOf(todo.isDone()));
column.setWidth(75);
column.setEditorBinding(doneBinding);

You also have an example here https://vaadin.com/forum/#!/thread/16520025

I don’t know if you have a better solution (I don’t use inline editor).

Note that if you need to, you can also use a Converter there with the Binder if you need to.

-Olli