2017-05-04 67 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現在觸發此方法,對我的作品在最新

版本