Vaadin table.select(itemId) is not working

断了今生、忘了曾经 提交于 2019-12-24 17:06:15

问题


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 }

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

EDIT:

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.


回答1:


This thread has the answer, thanks to @Teppo Kurki

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

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 we now can delete the table.select(itemId); in the initial post



来源:https://stackoverflow.com/questions/19572857/vaadin-table-selectitemid-is-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!