Search code examples
javascriptnativescriptnativescript-telerik-ui

Navigation scroll to matched elment in list items


Hi I Am new to native script. While learning native script I faced a problem that, I have a-z letters and list items side by side. When I tap any item in (a-z), list view must move to matched first letter in list items. Same as contact filter using alphabets. Is there any solution for this.


Solution

  • I suppose you are using the Nativescript-UI RadListView because of the tag you added to the question.

    You can use the scrollToIndex:

    let listView: RadListView = <RadListView>(frameModule.topmost().currentPage.getViewById("listView"));
    
    listView.scrollToIndex(50, false);
    

    Where 50 is the index of the item you want to scroll to and false is wether you want to animate the scroll or not.