This is a migrated thread and some comments may be shown as answers.

How to export specific data to pdf?

1 Answer 468 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bartłomiej
Top achievements
Rank 1
Bartłomiej asked on 02 Jan 2020, 08:53 AM
Can I export specific rows from grid to pdf? 
I found how to export page and all pages but not specific rows.

1 Answer, 1 is accepted

Sort by
1
Hetali
Telerik team
answered on 03 Jan 2020, 10:41 PM

Hello Bartłomiej,

In order to export only the specific Grid rows in the PDF, please follow either of the following two approaches:

1. Use the Grid rowClass callback to add a custom class to the non-specific rows and hide them in the exported document as described in the PDF Export Content Styling documentation. For example:

<kendo-grid [rowClass]="rowClass">
</kendo-grid>

public rowClass = args => ({
  "hide-in-pdf": args.dataItem.ProductID < 5     //Hide the rows with ProductID less than 5
});

.k-pdf-export .k-grid .hide-in-pdf {
  display: none;
}

Please take a look at this StackBlitz example where only the specific rows of the current Grid page are exported to the PDF.


OR


2. Create and show an off-screen Grid that holds the specfic Grid rows only by filtering the Grid data to a new array. Example:

<kendo-grid [data]="gridData">
  <ng-template kendoGridToolbarTemplate>
    <button class="k-button" icon="file-pdf" (click)="pdf.saveAs('off-screen.pdf')">
      Export to PDF
    </button>
  </ng-template>
</kendo-grid>

<div style="position: absolute; top: 0; left: -10000px; width: 500px;">
  <kendo-pdf-export #pdf paperSize="A4" [landscape]="'horizontal'">
    <kendo-grid [data]="data">
    </kendo-grid>
  </kendo-pdf-export>
</div>

public gridData: any[] = products;
public data = filterBy(this.gridData, {field: "ProductID", operator: "gte", value: "6"});   // Export all the rows from the Grid except first five.

In this StackBlitz example, you can export the specific rows of all the Grid pages to the PDF.


I hope this helps. Please let me know if you have any further questions pertaining to the PDF Export of the specific rows in the Kendo UI Grid.

Regards,
Hetali
Progress Telerik

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Bartłomiej
Top achievements
Rank 1
Answers by
Hetali
Telerik team
Share this question
or