I 'm Facing issue in case of fetching records of only selected checkbox row records in mat checkbox table in Angular 9.By check or uncheck of any record it gives total records instead of particular checkbox selected records. On Html file
<button mat-button class="btn order-secondery" (click)="exportPOErrorRecords()" [disabled]="isButtonEnable">
<mat-icon>save_alt</mat-icon>Export
</button>
On.ts file
exportPOErrorRecords() {
this.isAllCheckFlag = 'N';
if(this.isAllSelected()){
this.isAllCheckFlag = 'Y';
}
this._vendorFileService.exportPoErrors(this.selection.selected,this.isAllCheckFlag)
.subscribe(
(response: HttpResponse<Blob>) => {
let fileName = "vendorFileValidation.csv";
let binaryData = [];
binaryData.push(response);
let downloadLink = document.createElement('a');
downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, { type: 'text/csv' }));
downloadLink.setAttribute('download', fileName);
document.body.appendChild(downloadLink);
downloadLink.click();
}
)
}
isAllSelected() {
const numSelected = this.selection.selected.length;
const numRows = this.dataSource.data.length;
return numSelected === numRows;
}
Have no idea why getting undefined this.selection.selected case.
Aucun commentaire:
Enregistrer un commentaire