2017-05-04 144 views
1
<p-dataTable [value]="services" [paginator]="true" expandableRows="true" rowExpandMode="single"> 
...</p-dataTable> 

存在着一些这样的Primeng如何获得行的rowIndex扩展?

<ng-template let-col let-period="rowData" let-ri="rowIndex" pTemplate="body">...</ng-template> 

的数据表

回答

3

在您的NG-模板行的扩展使用下面的代码

<ng-template let-i="rowIndex"> 

    <button (click)="expand(i)"> expand </button> 
</ng-template> 

在此期间单击该按钮扩展使用下面的代码来获得rowindex

expand(i){ 
    //... your logic to expand the row... 
    this.expandedRowIndex = i; 
} 

<p-dataTable [value]="services" [paginator]="true" expandableRows="true" rowExpandMode="single" (onRowExpand)="onRowExpand($event)"> 

更新1: 当您单击要展开的整个行时。您可以使用<p-datatable>onRowExpand属性来实现此目的。

onRowExpand(cc){ 
    console.log(cc) 
    //logs the entire object which is clicked  
    } 

当行展开

enter image description here

LIVE DEMO

+0

这是唯一的方法吗? – alehn96

+0

这里面放置这个 alehn96

+0

你能创建一个plnker吗?你怎么扩展一个特定的行? – Aravind

0
<ng-template let-i="rowIndex" let-line pTemplate="rowexpansion"> 

rowIndex很可能加入到rowExpansion现在触发此方法,对我的作品在最新

版本
相关问题