This is a migrated thread and some comments may be shown as answers.

Scroll event

1 Answer 116 Views
ListView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nicola
Top achievements
Rank 1
Nicola asked on 06 Jun 2017, 01:00 PM

I need a way to know which element is entering and existing the view port of the list view as it's scrolled. Is there a scroll event for it?

I'm building a list of contacts and I would like to track the letter that we are currently in and show it to the end user. I was planning to use the header for the current letter. 

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 06 Jun 2017, 02:22 PM
Hello Nicola,

Yes, you can achieve this by tracking the itemIndex through itemLoading event.
For demonstration let's assume we are working with this example.

In your XML File declare the callback for itemLoading
<lv:RadListView  items="{{ dataItems }}"  itemLoading="onItemLoading">

and then in the code-behind file use the itemIndex to track which cell is currently shown from the top or from the bottom (depending on whether the user is scrolling top-to-bottom or bottom-to-top)
export function onItemLoading(args) {
    console.log("Currently showing cell with itemIndex: " + args.itemIndex);
}

Important: Currently the property is itemIndex but as of the next version of nativescript-telerik-ui plugin there might be a change in the API and the property might be renamed to index. The main idea is to have identical properties for both ListView and RadListView, so keep in mind that this might need some code change after the next official release. The change is logged here, and the issue will be updated once the change is in effect. Until then you can safely use itemIndex

Regards,
Nikolay Iliev
Progress Telerik
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Tags
ListView
Asked by
Nicola
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or