在nativescript + angular中使用RadListView时,有没有办法只为列表中的某些元素启用左/右行滑动?
谢谢
在nativescript + angular中使用RadListView时,有没有办法只为列表中的某些元素启用左/右行滑动?
谢谢
您可以,每次滑动都会点击itemSwipeProgressStarted
您必须返回的事件swipeLimits
。当您要禁用对特定项目的滑动操作时,将左/右限制设置为零 (0)。
这是基于项目状态的左视图示例。
dataItems: ObservableArray<any>;
...
onSwipeCellStarted(args: any) {
let status = this.dataItems.getItem(args.index).data.status;
const swipeLimits = args.data.swipeLimits;
const swipeView = args.object;
const deleteView: View = swipeView.getViewById('delete-view');
const editView: View = swipeView.getViewById('edit-view');
const disabledView: View = swipeView.getViewById('disabled-view');
if (status === 1) {
swipeLimits.left = editView.getMeasuredWidth() + deleteView.getMeasuredWidth();
swipeLimits.right = 0;
} else {
swipeLimits.left = 0;
swipeLimits.right = 0;
console.warn(' forbidden swipe...');
}
}
但我不确定这是否适用于 iOS。
也许您应该在 onCellSwiping 方法中重新定义视图,这是另一个示例,您可以根据 isItemVisible 参数替换滑动视图:
onCellSwiping(args: ListViewEventData) {
const swipeLimits = args.data.swipeLimits;
const swipeView = args['swipeView'];
this.mainView = args['mainView'];
this.leftItem = swipeView.getViewById('edit-view');
this.disabledItem = swipeView.getViewById('disabled-view');
let isVisible = this.mainView.bindingContext.isItemVisible;
if (isVisible) {
View.layoutChild(<View>this.disabledItem.parent, this.disabledItem, this.mainView.getMeasuredWidth(), 0, this.mainView.getMeasuredWidth(), 0);
} else {
View.layoutChild(<View>this.leftItem.parent, this.leftItem, this.mainView.getMeasuredWidth(), 0, this.mainView.getMeasuredWidth(), 0);
}
}
我还没有在 iOS 上测试过,但这应该适用于 Android 和 iOS。