tyl / field-binder

Vaadin FieldBinder Add-on
Apache License 2.0
2 stars 1 forks source link

Inline editing #9

Open mortoza opened 9 years ago

mortoza commented 9 years ago

Hi I was walking through Tutorial 4, noticed that column "Age" is editable and when I entered a number got exception. I understand this is because i entered number in calculated field. Question ism how can we set such column uneditable?

evacchi commented 9 years ago

The actual reason is that the default factory is not setting a Converter for that numeric field. This is easily fixed by declaring it explicitly:

    final BeanTable<Person> table = new BeanTable<>(Person.class, container);
    table.setVisibleColumns("firstName", "lastName", "age", "birthDate");
    final TextField age = table.getFieldBinder().build("age");
evacchi commented 9 years ago

As for the other question, you may attach to the itemEdit/itemCreate event; e.g.:

      table.getNavigation().addEditingModeChangeListener(event -> age.setReadOnly(true));

(in the last commit 574324284c9444a5e7d16b590b15e8b387ace202 I have also tuned the EditingModeChange event so that you may only attach to that; in the released version it won't work as expected because of the way fields are being initialized)