Vaadin-grid: How to "scroll" to activeItem?

Created on 11 Jul 2017  路  6Comments  路  Source: vaadin/vaadin-grid

Hello everyone,

setting the selection inside the grid via "activeItem" works nice, no issues.

BUT: what, if the item being selected is not in the currently visible area of the grid? How to "scroll" the grid to the correct position so that the activeItem becomes visible?

Regards,
Michael

bug

Most helpful comment

This doesn't work with vaadin-grid 5.0.0-pre.5: $0.$.scroller.scrollToIndex is undefined.
Is there any plan to make this a public/established API? Seems like this would resolve the issue (and could change as-necessary).
This does work: grid._scrollToIndex(0) where 0 is the first row (following the headers).

All 6 comments

Unfortunately, looks like it's a missing feature in the public API.

As a temporary solution, you can use the grid鈥檚 internal method directly: grid.$.scroller.scrollToIndex(i);. Warning: private API, can change anytime (although it鈥檚 unlikely to happen before grid v4.0 release).

Thx!

+1 for this

Is there a possibility to use the private API when the grid is sorted? When using the API on a sorted grid, it scrolls to to original position of the item not the current one based on the sorting.

This doesn't work with vaadin-grid 5.0.0-pre.5: $0.$.scroller.scrollToIndex is undefined.
Is there any plan to make this a public/established API? Seems like this would resolve the issue (and could change as-necessary).
This does work: grid._scrollToIndex(0) where 0 is the first row (following the headers).

Will be fixed by #1169

Was this page helpful?
0 / 5 - 0 ratings