I\'m trying to bring a data table layout with pagination that has checkbox selection for data in it. I\'m able to select a page\'s data and when I move to another page, and sele
The problem is discussed on github:
DataTable selection with pagination
To help you now:
HTML:
<p-dataTable [value]="data" [rows]="PageSize"
[paginator]="ShowPaginator" [pageLinks]="3" [(selection)]="selectedData"
(onHeaderCheckboxToggle)="onTableHeaderCheckboxToggle($event)">
<p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
</p-dataTable>
TS:
class Test {
private data: MyData[];
selectedData: MyData[];
onTableHeaderCheckboxToggle(event: any) {
if (event.checked === true) {
for (let m of this.data) {
if (/* Make your test here if the array does not contain the element*/) {
this.selectedData.push(m);
}
}
} else {
this.selectedData.length = 0;
}
}