I have a RadListView Nativescript + Angular element that I would like to delete items from via swipe action:
<RadListView [items]="stockList" id="listview" style="height: 100%; background-color: #f5f5f5;" swipeActions="true" pullToRefresh="true"
(pullToRefreshInitiated)="onPullToRefreshInitiated($event)"
(itemSwipeProgressEnded)="onSwipeCellFinished($event)"
(itemSwipeProgressStarted)="onSwipeCellStarted($event)"
(itemSwipeProgressChanged)="onCellSwiping($event)">
<ng-template let-item="item">
<GridLayout rows="*,*" colSpan="5" columns="*,2*,*,*" (tap)="onTap(item.name)">
<SVGImage col="0" row="0" rowSpan="2" class="pgrRating" [src]="pgrRating(item.PGR, item.raw_PGR)"></SVGImage>
<!-- TICKER -->
<Label row="0" col="1" horizontalAlignment="left" class="itemName" [text]="item.symbol"></Label>
<!-- COMPANY NAME -->
<Label row="1" col="1" horizontalAlignment="left" class="itemCompName" [text]="item.name"></Label>
<!-- LAST PRICE TODAY -->
<Label row="0" col="2" colSpan="2" horizontalAlignment="left" class="itemPrice"
[text]="'$' + (item.Last).toFixed(2)"
[ngClass]="item.Change == 0 ? 'black' : (item.Change > 0 ? 'green' : 'red')"></Label>
<Label style="color: #c00000" row="0" col="3" class="icon" text=""></Label>
<!-- $ CHANGE TODAY -->
<Label row="1" col="2" horizontalAlignment="left" class="itemChange"
[text]="item.Change.toFixed(2)"
[ngClass]="item.Change == 0 ? 'black' : (item.Change > 0 ? 'green' : 'red')"></Label>
<!-- % CHANGE TODAY -->
<Label row="1" col="3" horizontalAlignment="left" class="itemPriceChange"
[text]="item.Change > 0 ? ('(+' + item['Percentage '].toFixed(2) + '%)') : ('(' + item['Percentage '].toFixed(2) + '%)')"
[ngClass]="item.Change == 0 ? 'black' : (item.Change > 0 ? 'green' : 'red')"></Label>
</GridLayout>
</ng-template>
</RadListView>
Problem is, I'm not sure where to put the swipe template to retain the 'let-item ngFor' behavior to get the index of that item. The docs mention to put the template:
<GridLayout *tkListItemSwipeTemplate columns="auto, *, auto" class="gridLayoutLayout">
<StackLayout id="mark-view" col="0" class="icon" (tap)="onLeftSwipeClick($event)">
<Label text="mark" class="swipetemplateLabel" verticalAlignment="center" horizontalAlignment="center"></Label>
</StackLayout>
<StackLayout id="delete-view" col="2" class="" (tap)="onRightSwipeClick(item.index)">
<Label row="0" col="2" text="" class="icon swipeIcon" verticalAlignment="center" horizontalAlignment="center"></Label>
</StackLayout>
</GridLayout>
under the <ng-template> but if I do so, I lose out on the 'item' loop and then don't know how to pass the index. If I place the swipe template inside the ng-template to retain the item index, then the list displays a blank area where the template would be, so then my list can't occupy the whole height of the view.
Any advice? Thanks so much!!