Search code examples
javavaadinvaadin7vaadin-grid

Vaadin Grid : How to disable mouse event handler which runs inline editor?


I'm using Grid with switched-on editor (setEditorEnabled(true)), but I going to launch inline editor programmatically, by calling editItem() method. How to disable mouse event handler which runs inline editor?


Solution

  • Thanks @Morfic, I solved the problem as follows:

    Grid grid = new Grid(){
        @Override
        protected void doCancelEditor() {
            super.doCancelEditor();
            setEditorEnabled(false); // disable the editor every time when editing is completed
        }
    };
    
    grid.setEditorEnabled(false); // by default the editor is disabled
    
    ....
    // grid initialization
    ....
    
    // create any component (button for example) which will call the editor
    Button button = new Button("Edit");
    button.addClickListener((Button.ClickListener) event -> {
        grid.setEditorEnabled(true); // activate the editor when the desired event occurred
        grid.editItem(itemId); // call the editor with itemId (it may be selected itemId)
    });