【问题标题】:Primeng datatable issue with Angular 2?Angular 2 的 Primeng 数据表问题?
【发布时间】:2018-12-19 08:01:19
【问题描述】:

我正在使用Primeng(5.1.2)版本来显示网格数据,我想扩展该行的行以显示更多详细信息。

highlightRow(rowData: any, rowIndex: number) {
    return ((this as DataTable).isRowExpanded(rowData)) ? 'ui-state-hightlight' : '';
}

我收到一条错误消息,提示“无法读取未定义的属性 'isRowExpanded'”。我不知道为什么会发生此问题...?

【问题讨论】:

    标签: angular datatable primeng


    【解决方案1】:

    您可以通过参数传递 DataTable 并避免使用它。

    <p-table [columns]="cols" [value]="values" #dt>
    </p-table>
    

    当你调用函数时,你传递“dt”引用,然后在你的函数中

    highlightRow(dt: any, rowData:any, rowIndex: number){ 
       ....
    }
    

    【讨论】:

    • 我试过了,但同样的问题是未定义的 isRowExpanded。
    • dt.isRowExpanded(...) 给你未定义?
    • 我得到“dataTable.isRowExpanded 不是函数”
    • 你能把调用highlightRow函数的代码放在哪里吗?
    • 我在 上像这样从 [rowStyleClass]="highlightRow" 调用方法
    猜你喜欢
    • 2018-04-16
    • 1970-01-01
    • 2018-06-02
    • 2019-10-13
    • 2016-12-02
    • 1970-01-01
    • 2020-09-24
    • 2017-07-19
    • 1970-01-01
    相关资源
    最近更新 更多