Skip to content

setEnabled for the component editor fails with NPE #1281

Description

@anasmi

Grid-pro:1.0.0
Affected line: ((HasEnabled)grid.getColumnByKey("city") .getEditorComponent()).setEnabled(false);
Code to reproduce:

public class ProGridView extends VerticalLayout {
        GridPro<Person> grid;
        public ProGridView(){
                add(createGridPro());
                add(new Button("Change editor", e->{
//NPE here
       ((HasEnabled)grid.getColumnByKey("city")
            .getEditorComponent()).setEnabled(false);
                }));
        }
        private GridPro createGridPro(){
                grid = new GridPro<>();
                grid.addColumn(Person::getFirstName).setEditorComponent(new TextField()).setHeader("First Name").setKey("firstName");
                grid.addEditColumn(Person::getLastName).text((oldValue,newValue)->{}).setHeader("Last name").setKey("lastName");
                grid.addEditColumn(Person::getCity).select((oldValue,newValue)->{},
                        PersonRepository.getCities()).setHeader("Cities").setKey("city");
                grid.addEditColumn(Person::getAge);
                grid.setItems(new PersonRepository().getPersons());
                return grid;
        }
}

Might be related to this: https://github.com/vaadin/vaadin-grid-flow/issues/604

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions