Vaadin: I need to set the selected row, after I update table content. I have a Comboboxbutton containing different customers. Additionally I have two tables, the first shows main categories and the secound shows subcategories. Initially, no customer is selected, Main categories are shown, no subcategory is shown.
When I click on a category (lets say product for example!), sub-category table appers and shows sub-categories. When I change the customer now from empty to a specific customer, both tables are filtered, BUT: The product-selection is lost. I need to set the selection to the one selected before.
I get the table content as an sql-container object from antoher class.
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());
}
});
The sql-container which the getMainCats method returns, is created like this:
FreeformQuery subcatExtractionQuery = new FreeformQuery("select customerName from customers", connectionPool);
return new SQLContainer(subcatExtractionQuery);
The problem is, t tried different ways, but it didn't work. This was my try: https://vaadin.com/forum/#!/thread/1819417/1819416 But they use an indexcontainer, but I don't.
Can anybody explain how to do this WITHOUT an index container?
What about to use value of the table to get/set "selected" row?
Object value = mainCatTable.getValue();
mainCatTable.setContainerDataSource(source.getMainCats(currentCustomer));
mainCatTable.setValue(value);