TreeGrid scrollToIndex

Hello! I’am using Vaadin 14. The method scrollToIndex doesn’t work correctly!

Hi, could you describe in more detail how it behaves, i.e. what is not working correctly and possibly add some example code?

I can confirm that issue… if you initially expand the root items via code and also try to set the scroll index (e.g. scrollToIndex(4)) of a TreeGrid, there’s a render bug, where the top rows are displayed as empty (see screenshot before_sort.png). After sorting everything is displayed again.

18548306.png
18548309.png

Hi Christian,

I can give you some more information on that:

You should try the latest (LTS 14.4.9) or current version because the team did fix some problems regarding scrolling in the last few months, eg.:

https://github.com/vaadin/vaadin-grid/issues/1889

https://github.com/vaadin/vaadin-grid/issues/1808

https://github.com/vaadin/vaadin-grid/issues/2107

The last one also looks like your bug and it was fixed some weeks ago. Mostly it works now but there is a bug left for deeper tree hierarchies. See my comment in the last ticket.

Depending on your exact bug you’re hit there may be workarounds:

grid.getElement().executeJs(“setTimeout(function() { $0.scrollToIndex($1) })”, grid.getElement(), i);

or

UI.getCurrent().beforeClientResponse(grid, ctx → grid.scrollToIndex(i));

Regards

If you still have problems, please create a new bug. I’m glad to be not the only one having and reporting those bugs :slight_smile:

Thanks

I created a new ticket for that: https://github.com/vaadin/vaadin-grid/issues/2145

Thank you for the effort… I just requested a bug fix priority for that ticket, jfyi