TreeTable with HierarchicalContainer - does not work??

Hi guys,

I tried to set up a TreeTable with a HierarchicalContainer, but I will not work!
The Items I add will be displayed, but not within a hierarchy but on root level…

The code looks correct for me, many eyes see more than two … :wink:

Hope someone can give me a hint!

package com.example.test_treetable;

import com.vaadin.Application;
import com.vaadin.ui.TreeTable;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

public class Test_treetableApplication extends Application {
	public void init() {
		Window mainWindow = new Window("Test_treetable Application");
		VerticalLayout vl = new VerticalLayout();
		TreeTable tt = new TreeTable();
		HierarchicalContainer hc = new HierarchicalContainer();
		hc.addContainerProperty("CAPTION", String.class, "--");
		Item a = hc.addItem("a");
		Item b = hc.addItem("b");
		Item c = hc.addItem("c");
		hc.setChildrenAllowed(a, true);
		hc.setChildrenAllowed(b, true);
		hc.setChildrenAllowed(c, false);
		hc.setParent(b, a);
		hc.setParent(c, b);

I have tested with 6.7.3 and also latest 6.7.4 nightly build …


I have the same problem! I actually commented my own code and pasted source directly from and from (from add-on demo), and the hierarchy is flattened in EVERY example!

I am out of ideas on what else to try, I am very new to vaadin and I am still learning how to use widgets…

Thanks in advance!

Hi Martin,

You just did a little mistake.

When you do this :

Item a = hc.addItem("a");

You add an item to the container and specify that the new item identifier is “a” (not the variable
Item a

So, if you want to create the hierarchy , you simply change your call to the setParent method .

hc.setParent("b", "a");
hc.setParent("c", "b");

Hope it’s help.



Thank you for the hints! Having to dig deeper into this widget source was very educational for me,

We actually figured out what was wrong with great help from css developers on my team. The css styles v-treetable-treespacer, v-treetable-node-closed etc used by TreeTable were missing from my project, as well as the expand/collapse icon images! Once these were restored, all the controls and the hierarchy are working!

Yeah, same here, had to comment out this line:

$v-included-components: remove($v-included-components, treetable)