NativeScript Core

RadListView Scroll to Index

This tutorial describes how to scroll a specific item of the RadListView by it's index into the visible portion the UI.

Implementation

  1. All that you need to do is call the scrollToIndex() of the RadListView instance with an valid integer object as the 'index' parameter. The code snippet bellow shows the described approach, note that the snippet assumes there is an RadListView instance with id="listView" set in the XML.
let listView: RadListView = <RadListView>(Frame.topmost().currentPage.getViewById("listView"));

listView.scrollToIndex(50, false, viewModelContext.get('myScrollPosition'));

Changing the position of the scrolled to item (iOS only)

When scrolling the RadListView to show a previously not visible item the default beahvior is that the item will be scrolled into the view either in the Top or Left position depending on the current scrollDirection of the layout. You can easily change that default value by assigning the scrollPosition to one of these values ListViewScrollPosition.