nativescript-community / ui-collectionview

Allows you to easily add a collection view (grid list view) to your projects. Supports vertical and horizontal modes, templating, and more.
Apache License 2.0
59 stars 18 forks source link

How to get a specific item from the collection #37

Open Whip opened 2 years ago

Whip commented 2 years ago

I want to know how I can get a specific item's view from the collection using index or some other way. @farfromrefug told me about getViewForItemAtIndex in #17 but haven't been able to make it work. I need to do some work on each item of the list when the user presses a button (not part of collection). Here's my code:

const collection = page.getViewById('collection');

for (var i = 0; i < listItems.length; i++) {
  const listItem = collection.getViewForItemAtIndex(i);
  console.log(listItem); // undefined
}

Since there's no documentation on it, I'm just shooting in the dark here.