Nativescript-ui-feedback: Disable swipeAction event on specific items or template in RadListView

Created on 18 Oct 2017  路  3Comments  路  Source: ProgressNS/nativescript-ui-feedback

Did you verify this is a real problem by searching Stack Overflow?

Yes

Tell us about the problem

i am trying to disable the swipe action, reorder event on specific items of my ListView
( in my case i am grouping items by date and i want to disable the swipe action on the groupe header which is having template = header)

Which platform(s) does your issue occur on?

Both android and ios

Please provide the following version numbers that your issue occurs with:

  • Progress NativeScript UI version: 3.1.4
  • CLI 3.2.1:
  • Cross-platform modules: 3.2.0
  • Runtime(s): "tns-ios": "3.2.0"
    "tns-android": "3.2.0"

Please tell us how to recreate the issue in as much detail as possible.

  1. open the application : nativescript-ui-samples-angular
  2. add the following line to those events

onSwipeCellStarted, onSwipeCellFinished, onCellSwiping

if (args.index ===1 || args.index ===2 ) {
      return 0 ;
    }

this will prevent the event on the specefied items but when you swipe an item of index different than 1 or 2 the swiping event will be activated to the items 1 and 2.

question

All 3 comments

i tried to use "isUserInteractionEnabled" attribute on ng-template but it's not working.
isUserInteractionEnabled

Gets or sets a value indicating whether the user can interact with the view. This does not affect the appearance of the view.

Hello @crostina

You can not use isUserInteractionEnabled on the Angular ng-template.
However, you can change the approach and disable the swipe actions by assigning different swipe limit rules depending on the item index.

For example:

export function onSwipeCellStarted(args: listViewModule.SwipeActionsEventData) {
    console.log(args.index); // use the item index to assign or limit the swipe limits

    if (args.index >= 3) {
        var swipeLimits = args.data.swipeLimits;
        var swipeView = args.object;
        var leftItem = swipeView.getViewById<viewModule.View>('mark-view');
        var rightItem = swipeView.getViewById<viewModule.View>('delete-view');
        swipeLimits.left = leftItem.getMeasuredWidth();
        swipeLimits.right = rightItem.getMeasuredWidth();
        swipeLimits.threshold = leftItem.getMeasuredWidth() / 2;
    } else {
        var swipeLimits = args.data.swipeLimits;
        var swipeView = args.object;
        var leftItem = swipeView.getViewById<viewModule.View>('mark-view');
        var rightItem = swipeView.getViewById<viewModule.View>('delete-view');
        swipeLimits.left = 0
        swipeLimits.right = 0;
        swipeLimits.threshold = 0;
    }
}

With the code above the swipe limit for the first three items are set to 0 which means that the user won't be able to interact with them.

Hello NickIliev
your solution solved my issue thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings