I have a table which checkbox header and on checking the checkbox only few rows base on the condition need to be checked and on unchecking the box selected checks need to be disappear.
HTML
<p-table [value]="_rows" [columns]="columns" [(selection)]="selectedRows">
<p-tableHeaderCheckbox id="selectAllRows" (click)="selectRow()"></p-tableHeaderCheckbox>
<p-tableCheckbox [value]="row" (click)="selectRow()" [disabled]="row.userDefined==='N'">
</p-tableCheckbox
></p-table>
JS
selectRow() {
this.selectedRows = this.selectedRows.filter(value => value.flag === 'Y');
this.selectedEvent.emit(this.selectedRows);
}