【问题标题】:Vaadin Grid : How to disable mouse event handler which runs inline editor?Vaadin Grid:如何禁用运行内联编辑器的鼠标事件处理程序?
【发布时间】:2016-08-12 11:06:44
【问题描述】:

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

【问题讨论】:

  • 您是否在默认情况下尝试setEditorEnabled(false);,在您的按钮单击侦听器(或您拥有的任何to launch inline editor programmatically)中,在关闭编辑器后再次调用setEditorEnabled(true); editItem(itemId);setEditorEnabled(false);
  • 谢谢@Morfic!有用!我在我的事件监听器中添加了 setEditorEnabled(true) 并在重写的 doCancelEditor() Grid 方法中添加了 setEditorEnabled(false)
  • 太好了,那么您可以在答案中发布您的解决方案并将其选为正确的,这样任何可能遇到相同问题的人都可以找到它:-)

标签: java vaadin vaadin7 vaadin-grid


【解决方案1】:

感谢@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)
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 1970-01-01
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多