Skip to content

How can I filter the prime ng table and export only filtered data to excel #1714

Discussion options

You must be logged in to vote

I am able to figure it out I added one more property in my component

@Input()
filteredvalues: any[] = [];

Added onfilter method (onFilter)="onFilter($event)"

onFilter(event: any) {
    this.filteredvalues = event.filteredValue;
}

Imported the component as viewchild @ViewChild('dt1') table!:PrimeTableComponent;
and on export I did this

exportToExcel() {
   if (this.table.filteredvalues && Array.isArray(this.table.filteredvalues)) {
   let data: any[] = [];
   this.table.filteredvalues.forEach((employee: any) => {
   const rowData: any = {
   'Employee ID': employee.employeeId,
   'Full Name': employee.employeeName,
   'Email': employee.emailId,
   'Billing Status': employee.billingStatus…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Github743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant