Reputation: 25790
I added Details to the Grid compoenent. Each time I click on Grid row - the details expand. For example I clicked on the first Grid row which have long Details content. Everything fine so far. But when I scroll down to the row #2 and cliked on it, row#1 details collaps, and row#2 details opens. And now on the screen I see the row #7 (because row#1 details were long ).. but I expect to see the row#2. How to properly scroll into the view the row#2?
the following unfortunately doesn't work:
grid.addItemClickListener(e -> {
e.getColumn().scrollIntoView();
});
Another question - is there a way to not automatically collapse row #1 when I click on row #2?
Upvotes: 0
Views: 467
Reputation: 25790
Found the answer in the official documentation https://vaadin.com/docs/latest/components/grid/flow/#enabling-expanding-rows
Implemented in the following way:
grid = new Grid<>();
grid.setDetailsVisibleOnClick(false);
grid.addItemClickListener(e -> {
grid.setDetailsVisible(e.getItem(), !grid.isDetailsVisible((e.getItem())));
});
Upvotes: 2