Java Vaadin网格:如何禁用运行内联编辑器的鼠标事件处理程序?

Java Vaadin网格:如何禁用运行内联编辑器的鼠标事件处理程序?,java,vaadin,vaadin7,vaadin-grid,Java,Vaadin,Vaadin7,Vaadin Grid,我将网格与打开的编辑器(setEditorEnabled(true))一起使用,但我将通过调用editItem()方法以编程方式启动内联编辑器。如何禁用运行内联编辑器的鼠标事件处理程序?谢谢@Morfic,我解决了以下问题: Grid grid = new Grid(){ @Override protected void doCancelEditor() { super.doCancelEditor(); setEditorEnabled(fals

我将网格与打开的编辑器(setEditorEnabled(true))一起使用,但我将通过调用editItem()方法以编程方式启动内联编辑器。如何禁用运行内联编辑器的鼠标事件处理程序?

谢谢@Morfic,我解决了以下问题:

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)
});

您是否尝试过
setEditorEnabled(false)以编程方式启动内联编辑器
)调用
setEditorEnabled(true);编辑项(itemId)&
setEditorEnabled(false)关闭编辑器后再次?谢谢@Morfic!它起作用了!我在我的事件侦听器中添加了setEditorEnabled(true),在重写的doCancelEditor()网格方法中添加了setEditorEnabled(false)。很好,然后您可以在答案中发布您的解决方案,并将其选为正确的解决方案,这样可能存在相同问题的任何其他人都可以找到它:-)