Nativescript Delete button not showing in RadListView with swipecell

91 views Asked by At

Well going through {N} tutorial I want to achieve this :

Expected

But I have trouble showing this delete button.

There is no problem with the image it shows well somewhere else and I also tried putting a Label instead but same result.

Rad Listview component :

<RadListView row="1" [items]="groceryList"
  swipeActions="true" (itemSwipeProgressStarted)="onSwipeCellStarted($event)">

    <ng-template let-item="item">
      <Label [text]="item.name" class="p-15"></Label>
    </ng-template>

    <GridLayout *tkListItemSwipeTemplate columns="*, auto">
      <StackLayout id="delete-view" col="1" (tap)="delete($event)" class="delete-view">
        <Image src="~/images/delete.png" ></Image>
      </StackLayout>
    </GridLayout>

  </RadListView>

CSS :

.delete-view {
    background-color: #CB1D00;
    padding: 20;
}
.delete-view Image {
    color: white;
    height: 25;
}

TS

onSwipeCellStarted(args: ListViewEventData) {
    var swipeLimits = args.data.swipeLimits;
    var swipeView = args.object;
    var rightItem = swipeView.getViewById<View>("delete-view");
    swipeLimits.right = rightItem.getMeasuredWidth();
    swipeLimits.left = 0;
    swipeLimits.threshold = rightItem.getMeasuredWidth() / 2;
  }

  delete(args: ListViewEventData) {
    let grocery = <Grocery>args.object.bindingContext;
    this.groceryService.delete(grocery.id)
      .subscribe(() => {
        let index = this.groceryList.indexOf(grocery);
        this.groceryList.splice(index, 1);
      });
  }

Deletion feature works well but all what i am getting when swiping is this :

Result

What am I getting wrong here ?

1

There are 1 answers

2
David On

I spent several days earlier this month wrestling with similar issues with RadListView, especially on iOS. It seems to defy logic. I ended up using a negative padding to get to where I could see my labels and icons. If that doesn't help, try removing height: from your css.