Vaadin 设置选定行 table

Vaadin set selected row of table

Vaadin:我需要在更新 table 内容后设置所选行。 我有一个包含不同客户的 Comboboxbutton。 此外,我还有两个 table,第一个显示主要类别,第二个显示子类别。 最初,未选择客户,显示主要类别,不显示子类别。

当我点击一个类别(比如产品!)时,子类别 table 出现并显示子类别。 当我现在将客户从空客户更改为特定客户时,两个 table 都被过滤,但是:产品选择丢失了。我需要将选择设置为之前选择的那个。

我从其他 class.

中获取 table 内容作为 sql 容器对象
mainCatTable = new Table();
...
mainCatTable.setContainerDataSource(source.getMainCats());

//My Checkboxbutton
Combobox custBox = new ComboBox();

//Get the customers from the Database
custBox.setContainerDataSource(source.getCustomers());

custBox.setItemCaptionPropertyId("Customers");
custBox.addValueChangeListener(new ValueChangeListener() {
     public void valueChange(ValueChangeEvent valueEvent) {  

//Here I need to store the old selection, before i update the mainCat table to a specific customer  
          mainCatTable.setContainerDataSource(source.getMainCats(currentCustomer));

//Here I need something to set the selected row to the previous value
          subCatTable.setContainerDataSource(source.getSubCats());
          }
});

getMainCats 方法 returns 的 sql-容器是这样创建的:

FreeformQuery subcatExtractionQuery = new FreeformQuery("select customerName from customers", connectionPool);
return new SQLContainer(subcatExtractionQuery);

问题是,我尝试了不同的方法,但都没有用。 这是我的尝试: https://vaadin.com/forum/#!/thread/1819417/1819416 但是他们使用索引容器,而我没有。

任何人都可以解释如何在没有索引容器的情况下执行此操作吗?

如何使用 table 到 get/set "selected" 行的值?

Object value = mainCatTable.getValue();    
mainCatTable.setContainerDataSource(source.getMainCats(currentCustomer));
mainCatTable.setValue(value);