TreeTable does not accept Embedded.class as first element

Hi,

I have the following code, which works fine:
partEnExtFacTree.addContainerProperty(“partEnExtFac”, String.class, null);
partEnExtFacTree.addContainerProperty(“gerelateerd”, Embedded.class, null);

partEnExtFacTree.setColumnHeader(“partEnExtFac”, “Naam”);
partEnExtFacTree.setColumnHeader(“gerelateerd”, “”);

partEnExtFacTree.setVisibleColumns(new Object {“partEnExtFac”, “gerelateerd”});

ThemeResource gerelateerdIcon = new ThemeResource(ONETOMANYICON);
Embedded gerelateerdEmbedded = new Embedded(“gerelateerd”, gerelateerdIcon);

partEnExtFacTree.addItem(setPartEnExtFactItem(naamPartExtFact, gerelateerdEmbedded), code);

final Object setPartEnExtFactItem(String naam, Embedded gerelateerd) {
return new Object {
naam, gerelateerd};
}

But what I actually want is to have the Embedded Icon as the first element in the TreeTable:
partEnExtFacTree.addContainerProperty(“gerelateerd”, Embedded.class, null);
partEnExtFacTree.addContainerProperty(“partEnExtFac”, String.class, null);

partEnExtFacTree.setColumnHeader(“gerelateerd”, “”);
partEnExtFacTree.setColumnHeader(“partEnExtFac”, “Naam”);

partEnExtFacTree.setVisibleColumns(new Object {“gerelateerd”, “partEnExtFac”});

ThemeResource gerelateerdIcon = new ThemeResource(ONETOMANYICON);
Embedded gerelateerdEmbedded = new Embedded(“gerelateerd”, gerelateerdIcon);

partEnExtFacTree.addItem(setPartEnExtFactItem(naamPartExtFact, gerelateerdEmbedded), code);

final Object setPartEnExtFactItem(String naam, Embedded gerelateerd) {
return new Object {
gerelateerd, naam};
}

Unfortunately this results in not showing the TreeTable. Is there a solution for this? I have searched all forums, but could not find any.

Thanks for any help,
Mischa

15740.png

Well, the first column in TreeTable is fixed to be a tree, and you would be having components as tree items, which isn’t supported - they have to be textual.

You seem to be trying to do is implement item icon column. For that, you should be able to use setItemIcon() or setItemIconProperty(). I hope it works with TreeTable as well.

Thanks Marko, for this suggestion. It works but now I want to attach an eventlistener only to the icon and another to the text after the icon. Is such a thing possible? I cannot seem to find any listeners which are directed towards the icon only.

Cheers,
Mischa

I solved the whole problem, by putting a layout as the first element of my tabletree.
The layout has the icon as first element, and label as second element in it.
I added a seperate listener to the layout. Which listens to which layoutcomponent is clicked.

Solved!