【问题标题】:Dynamic change of itemRorder value in RadListView UI in Nativescript Angular appNativescript Angular 应用程序中 RadListView UI 中 itemRorder 值的动态更改
【发布时间】:2019-01-19 18:13:23
【问题描述】:

我正在尝试动态更改 Nativescript Angular App 的 RadListView Ui 列表中 itemReorder 布尔值的值,但没有成功。每次出现此错误:行为未附加到 RadListView,请使用 RadListView addbehavior 方法附加它。

HTML:

<GridLayout  tkExampleTitle tkToggleNavButton class="proposedLettersRow">
        <RadListView #itemReord [items]="items" selectionBehavior="LongPress" reorderMode = "Drag" [itemReorder]="itemReorder" (itemReordered)="onItemReordered($event)" multipleSelection= "false"
                    >
                <ng-template tkListItemTemplate let-item="item">
                    <GridLayout class="listItemTemplateGrid" >
                        <Label
                            [text]="item"
                            [ngClass]="!isWin ?  'proposed' : 'proposedIsDone'"
                            class="list-group-item ">
                        </Label>
                    </GridLayout>
                </ng-template>

                <ListViewGridLayout tkListViewLayout
                                    scrollDirection="Vertical"
                                    height="150"
                                    ios:itemHeight="150"
                                    spanCount="7"
                                    horizontalAlignment="center">
                </ListViewGridLayout>
        </RadListView>
    </GridLayout>

打字稿:

一开始this.itemReorder设置为true,然后一个函数来将其更改为false,执行此函数时出现错误。

Terminal log

Code

【问题讨论】:

  • 您能否在文本中添加代码,而不是通过问题中的图像。
  • 我已经编辑添加这个
  • 我无法重现该问题,让我们知道您是否可以使用您的代码更新此Playground
  • Playground 更新,代码重现问题:play.nativescript.org/?template=play-ng&id=EjIK8s&v=2@Manoj
  • 向上拖动一个元素会导致 App @Manoj 崩溃

标签: angular nativescript radlistview


【解决方案1】:

我认为您将itemReorder 设置为false 为时过早,可能是组件在itemReordered 事件中要求它为true。由于它还不是开源的,所以我没有太多关于这方面的信息。但一个简单的解决方法是添加超时,

public youWin() {
    if (this.newIndex < this.oldIndex) {
        setTimeout(() => {
            this.itemReorder = false;
        }, 100);
    }
}

Updated Playground

【讨论】:

    猜你喜欢
    • 2017-06-22
    • 2017-03-10
    • 2019-07-06
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    相关资源
    最近更新 更多