Bastien
Bastien

Reputation: 103

How to scroll down to a specific index of a list contained in a Scrollview ? (Nativescript-vue)

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.

Upvotes: 3

Views: 1407

Answers (1)

Manoj
Manoj

Reputation: 21908

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.

Upvotes: 3

Related Questions