3

I'm writing a mobile application using nativescript-vue.

I have a list contained in a Scrollview (which is contained in a Tabview). When my app goes to this tab, I want the Scrollview to scroll down to a specific index of the list that is contained.

I tried this :

<ScrollView id="ScrollView" @loaded="onLoaded">
    <ListView for="item in items" class="list-group">
     ...

onLoaded() {         
this.$refs.page.nativeView.getViewById("ScrollView").scrollToVerticalOffset(200, false);
}

This does not work, whatever the value for the offset parameter.

Do I miss something?

Thank you in advance.

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
Bastien
  • 103
  • 8

1 Answers1

3

It's a mistake to wrap ListView within ScrollView as ListView itself is scrollable. You may use scrollToIndex on RadListView to scroll down / up to specific index.

// Scrolls to 50th index
listView.scrollToIndex(50);

Also make sure your items are populated on UI before you call this method. I think you should use dataPopulatedEvent for that.

Manoj
  • 21,753
  • 3
  • 20
  • 41