Vaadin table.select(itemId) 不起作用 [英] Vaadin table.select(itemId) is not working

查看:23
本文介绍了Vaadin table.select(itemId) 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表绑定到 SQLContainer 和一个插入按钮(在表中插入一行)

I have a table bind to a SQLContainer and a insert button (that insert a row in the table)

当按钮被点击时,它会执行下面的监听器代码:

When the button is clicked it execute the below code of the listener:

Object itemId = table.addItem();
container.getContainerProperty(itemId, "cedula").setValue(cedulaS);

try {
    container.commit();
    table.select(itemId);
catch (UnsupportedOperationException e) { //bla }

该行已正确插入但我希望自动选择该行但 select 方法不起作用有什么想法吗?

The row is properly inserted BUT I want that automatically the row be selected but the select method is not working any idea?

select(ItemId) 正在工作,它选择了行,但由于某种原因,提交行使 select(ItemId) 不起作用.我认为是因为 itemId 是一个临时行,所以当提交被执行时它会消失或丢失它的值.

The select(ItemId) is working and its select the row BUT for some reason the commit line make that the select(ItemId) didnt works. I think is because itemId is a temporary row, so when the commit is execute it disappear o lose its values.

推荐答案

这个帖子有答案,感谢@Teppo Kurki

This thread has the answer, thanks to @Teppo Kurki

https://vaadin.com/forum#!/thread/4268146

问题是 itemId 是一个临时行 ID,所以当执行提交时,我更改了行 ID,因此必须实现以下侦听器:

The problem is that itemId is a temporal row id so when the commit is executed iy changed the row id, so it must be implemented the below listener:

container.addRowIdChangeListener(new QueryDelegate.RowIdChangeListener() {
  void rowIdChange(QueryDelegate.RowIdChangeEvent event) {
      table.select(event.getNewRowId());
   }
});

Ant 我们现在可以删除 table.select(itemId);在最初的帖子中

Ant we now can delete the table.select(itemId); in the initial post

这篇关于Vaadin table.select(itemId) 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆