hi guys, how can i add dinamically a child in a tab of a vaadin tabs, like in the TreeGrid? Specifically i need to create child when a tab is selected
Here’s an example with two alternative approaches:
Tabs tabs = new Tabs();
Tab clickableTab = new Tab("Click this to add a new Tab");
Tab tabInSelectionEvent = new Tab("Select this to add a new Tab");
clickableTab.getElement().addEventListener("click", clickEvent -> {
Tab newTab = new Tab("New " + System.currentTimeMillis());
tabs.addComponentAtIndex(tabs.indexOf(clickableTab), newTab);
});
tabs.addSelectedChangeListener(selectedChangeEvent -> {
if (tabInSelectionEvent.equals(tabs.getSelectedTab())) {
Tab newTab = new Tab("New " + System.currentTimeMillis());
tabs.addComponentAtIndex(tabs.indexOf(tabInSelectionEvent), newTab);
}
});
tabs.add(clickableTab, tabInSelectionEvent);
add(tabs);
thanks a lot