Howto: TreeTable

Can someone please write a short snippet on how to:

  1. Fill a treeviewtable with data (f.e. Name, icon, description, dropdown). Especially focus on how to have different components in the columns of a row. The samples provided hide that kind of details…

  2. How to use a Collapsible (?) container, to use as datasource for a treeViewTable.



Sorry for my confusion… I am talking about:
Vaadin TreeTable -

When I add a Resource column to my TreeTable:

       table.addContainerProperty("Enabled", Resource.class, 0); 

and add an element, setting this property to a ThemeResource:


It is rendered as Text, the name of the picture, but not the picture itself!?

I see that


makes a image-column for the “type”-column.

Can I add further image columns to a TreeTable - and how do I do that?

Okay, no reply so long… anyway.

I see that it is possible to set at least on picture per row:


But how can I prevent that column then from rendering twice: once as icon column and once as default text column?


Come on - anyone!?

Can I have every component at the TreeTable rows/columns as at the default vaadin table? How?
How can I hide columns from being displayed?


Okay, I can see I can display buttons and checkboxes in a TreeTable. How do I show one or more images?
The only way I found so long by:


just allows one single image?
Is it supported with more than one image-columns on vaadin table / TreeTable?


You can add images to cells if you use Embedded component.


Thanks a lot. That worked it out!
Examples show use of “Resource” as column type - which does not work for me.


Another question, vaadin TreeTable:


  • SubNode0
  • SubNode1

When SubNode1 is clicked in a TreeTable, how can I detect all nodes that are “above” Subnode1 as which node being the parent of SubNode1 - out of the EventHandler:

treeTable.addListener(new ItemClickEvent.ItemClickListener() {
            public void itemClick(ItemClickEvent e) {
            //impl goes here



Another question: Sorting.

in sorting is mentioned, but its not shown how to implement custom sorting for table/treeTable.

Please post a sample on how to sort rows of a table.


Q1: Table.getParent(ItemId) does the trick.

Any help on Q2 (sorting) appreciated!!!

Which columns are sortable depends on what Table.getSortablePropertyIds() returns, so you can simply click the table header cells to sort those columns. You can override the method if necessary.

If I remember correctly, by default, columns whose types in the container implement Comparable are sortable. Therefore, if using a custom data type, you can implement custom sorting by implementing Comparable in your data type.

You can also handle custom sorting by implementing your own and setting it for the container of the table. See One test using a custom sorter is in

Perfect - thank you!!

Two more comments after using vaadin treeTable now for a while:

  1. I think its quite “nifty” to set TreeNode-Properties on the table itself for each node, instead of setting properties on the nodes, which are added to the table on the way…
  2. The behaviour of disabling children for an item, adding children for that item, which will we attached to the next node having children allowed is strange. And can quickly lead to unexpected behaviour. Consequently I would runtime expect to throw an exception when adding children to a node that does not allow it. Or just drop that property, and render the child expander just in case children exist - most feasible and intuitive.

Pretty great work anyway - Thanks Vaadin Team!!

If adding works as you say, I would consider that a bug - please
file a ticket

As for the latter suggestion, I believe it would in practice eliminate much of lazy loading in many applications, as you would have to do a large number of checks to see if certain nodes actually have children - sometimes that check can be very expensive.

Okay, want to - but my forum login does not apply there? What is the login to use then?

I think this is the default behaviour of all other TreeViews if been working with so long. Even, as traversing the tree server side, should not be the big deal…

Did not see the “register” menu entry at first…

Ticket is here:

Rock on - Vaadin Team!!!


How did you put icons in the table? Do you have code snippet?

The other two problems that I have on my hand are that I have to show data in Pivots and I am using TreeTable for this.

I am posting two images to elaborate what I am asking.

One is how to put text “Grand Totals” in the last row as I have show in image pivot.png

the code I am using is…

	    Object [] totalsPos = new Object [pivotDepth]

for(int i =0;i<headers.length;i++){
= totals.get(headers[i]
= “”;
///////////////// This is here that I am putting value in the last row that is grand totals row
Object addGrandTotals = tr.addItem(totalsPos,“GTOT”);
// tr.setColumnHeader(“GTOT”, “G. Totals”);
//System.out.println(" tr.getContainer "+ tr.getContainerProperty(addItems[1]
tr.setChildrenAllowed(“GTOT”, false);

The other problem is that when now I have to show pivot like this in TreeTable or using some other idea like using Labels etc or other API to show Pivot like in the image file pivot2.gif

Is there a way that will enable us to use wrapper around GWT component so that GWT Pivot api can be used to display Pivot tables in Vaadin…