I am wondering how to retrieve the context of a tapped item in a listview. For example, if there are three items in the list, how can I determine that the second item was clicked and access the data related to that item in the observable array?
For instance, in the list template below, if a user taps on the second connection in the list of connections, how can I retrieve the data associated with that connection based on the index of the clicked item?
<ListView items="{{ connections }}" loaded="" itemLoading="" itemTap="">
<ListView.itemTemplate>
<StackLayout class='connection-li'>
<GridLayout class="connection-info" rows="" columns="auto, *, *" tap="goToMeasurements">
<Image col="0" src="res://ic_person_black_36dp" stretch ="none" />
<Label col="1" class="connection-name" text="{{ PatientFirstName + ' ' + PatientLastName }}" textWrap="false" />
<Image col="2" verticalAlignment="middle" horizontalAlignment="right" src="res://ic_cancel_black_18dp" stretch ="none" />
</GridLayout>
</StackLayout>
</ListView.itemTemplate>
</ListView>
UPDATE: According to the documentation, I have found an event that allows me to capture the index data. However, how can I specify which ListView I want to target when it refers to all ListViews? Is there a way to assign a specific reference or class to access it?
listView.on(listViewModule.ListView.itemTapEvent, function (args: listViewModule.ItemEventData) {
var tappedItemIndex = args.index;
var tappedItemView = args.view;
//// Do something
});