Hi,
There is a treetable. The treetable is initialized like this:
[code]
…
trtbMain.setColumnHeader(“col1”, “Header 1”);
trtbMain.setColumnHeader(“col2”, “Header 2”);
trtbMain.setSelectable(true);
trtbMain.setSizeFull();
trtbMain.addContainerProperty(“col1”, String.class, null);
trtbMain.addContainerProperty(“col2”, String.class, null);
trtbMain.addExpandListener(this::trtbMainExpandListener);
trtbMain.addItemClickListener(this::trtbMainItemClickListener);
trtbMain.addStyleName(“borderless”);
…
private void trtbMainItemClickListener(com.vaadin.event.ItemClickEvent itemClickEvent) {
...
}
[/code]I want to do some job when an item is selected and another job when the item is deselected. These jobs doesn’t have any visual output but there are 2 issues:
-
If I go with
itemClickEvent.getItem()
;
item
never becomes
null
after the first selection. If selected item is reclicked to deselect it,
the item
remains the same. If another one is clicked,
the item
becomes the
newly clicked item
. -
If I go with
trtbMain.getValue()
; after the first click on an item,
the value
is
null
but item appears to be selected and its row is blue. After the second click on the same item,
the value has some value
but the item row appears
not
to be selected.
Am I doing something wrong? How can I handle TreeTable’s itemClickListener properly?
Thank you…