primeng icon indicating copy to clipboard operation
primeng copied to clipboard

There should be a master button for expanding and collapsing all row groups of PrimeNg table

Open akashdeepg12 opened this issue 9 years ago • 2 comments

There should be a master button for expanding and collapsing all row groups of PrimeNg table. I have tried in custom way by using below code

In html : <p-dataTable selectionMode="single" [value]="tabData" #myDataTable>

In Ts : @ViewChild('TransactionDataTable') myDataTable;

logic : if(this.enableExpandCollapseRowGroups){ this.myDataTable.expandedRowsGroups = groupNameArray; // to expand }else{ this.myDataTable.expandedRowsGroups = []; // to collapse }

This is working in single tab PrimeNg dataTable. But this is not working properly in case of multiple tab . Still I'm unable to achieve this functionality. Is there any way to achieve this functionality ?

akashdeepg12 avatar Aug 16 '17 10:08 akashdeepg12

By multiple tab table, you mean paged table? If so, I managed to achieve this with the code below.

Component: cars: any[]; expandedItens: any[]; allExpanded: boolean; ngOnInit() { this.cars = carsData; //Load the data on the source array that the DataTable is loking at this.allExpanded = false; //By default, rows will not be expanded at fisrt } onclick() { this.allExpanded = !this.allExpanded; this.expandedItens = (this.allExpanded) ? [...this.cars] : []; }

Template: < p - dataTable [value]="cars" [rows]="5" [paginator]="true" [pageLinks]="3" expandableRows="true" [expandedRows]="expandedItens" > < p - header > < button pButton type="button" (click)="onclick()" label="Expand All!">< / button > < / p - header > Table content here < / p - dataTable >

GuzzoLM avatar Aug 16 '17 13:08 GuzzoLM

p-dataTable is deprecated and will be removed in favor of the new p-table (aka TurboTable) of 5.1.0 so closing the issue. Please try the new p-table once 5.1.0 is released.

cagataycivici avatar Jan 13 '18 22:01 cagataycivici