HI ,
How to detect click event of table row and when click on it open new tab and pass some params to new tab
Hi,
The CellClickListener
interface will help you:
myTable.setClickListener("clickableColumnName", (item, columnId) -> {
openWindow("AnotherTab", WindowManager.OpenType.NEW_TAB, ParamsMap.of("parameter", item.getInstanceName()));
});
Hello. What if I want a listener for a whole row?
Hi Ivan,
- setItemClickAction() for double click on a row:
ordersTable.setItemClickAction(new BaseAction("whatever") {
@Override
public void actionPerform(Component component) {
showNotification(ordersTable.getSingleSelected() + " clicked");
}
});
- setClickListener() for single click on a cell, that can be applied separately for each column:
ordersTable.setClickListener("date", ((item, columnId) -> {
showNotification(item.getInstanceName() + " in " + columnId + " clicked");
}));
ordersTable.setClickListener("amount", ((item, columnId) -> {
showNotification(item.getInstanceName() + " in " + columnId + " clicked");
}));
ordersTable.setClickListener("customer", ((item, columnId) -> {
showNotification(item.getInstanceName() + " in " + columnId + " clicked");
}));
so if i want to react on a table selections i have to add listeners to each column i have on a table or use datasource change listeners?
Thanks, that’s a good option.
But it doesn’t work with an editable cell. How can I intercept a click on input field in this case?
Update:
OK, I have a solution.
Maybe will be useful for somebody:
just unwrap also a textField and add a focus listener:
textField.unwrap(com.vaadin.ui.TextField.class).addFocusListener(event -> {
// custom code
});
A post was split to a new topic: Open different screens after double click basing on the selected column