DPF Export returns grid headers but ignores all data.

1 Answer 114 Views
Grid
Andrew
Top achievements
Rank 1
Andrew asked on 24 Sep 2021, 02:58 PM

I am exporting a jquery grid to PDF with saveAsPD(); I am setting pdf on grid initializing to 

pdf : {
multiPage: true,
allPages: false,
landscape: true,
repeatHeaders: true,
scale: 0.5,
creator: "John Snow",
margin: { top: "1cm", right: "1cm", bottom: "1cm", left: "1cm" },
 }

 If I am trying to change pdf options, creator for example, the created pdf has just headers and no data.

kendoGrid.setOptions({pdf: {creator: 'Sansa Stark'}});
kendoGrid.saveAsPDF();

The request to the new data is executed but data are not rendered, no a single row :(.

Can anybody help?

P/S Just in case pdf export handler:

pdfExport: (e) => {
const grid = kendo
.jQuery(this.gridConfigurationTemplate.nativeElement)
.data('kendoGrid');
const removableColumns = [];
grid.columns.forEach((col, index) => {
if (!col.ColumnId) {
removableColumns.push(index);
}
});
if (removableColumns.length) {
removableColumns.forEach((i) => {
grid.hideColumn(i);
});
e.promise.done(() => {
removableColumns.forEach((i) => {
grid.showColumn(i);
});
});
}
},

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 29 Sep 2021, 11:03 AM

Hi Andrew,

I have reviewed the provided code and it seems that you are hiding all the columns when the Grid is exported to PDF. 

 if (removableColumns.length) {
            removableColumns.forEach((i) => {
                 grid.hideColumn(i);
            });

Could you please try to comment out the row marked in yellow above and test the behavior?

Here is a Dojo example based on the provided snippet. As you will see, if the mentioned row is removed, the Grid is exported as expected.

If the provided suggestion does not resolve the issue, could you please try to modify the Dojo example in order to replicate the behavior the way it is on your side and send it back? This way we could investigate locally and advise you further. 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Andrew
Top achievements
Rank 1
commented on 29 Sep 2021, 02:12 PM

Thanks for the answer but problem was not there 

I moving  saveAsPDF call to dataBound event  fixed the issue. 

Andrew

Neli
Telerik team
commented on 04 Oct 2021, 08:26 AM

Hi Andrew,

I am glad to hear that you have managed to resolve the issue by yourself. Thank you very much for sharing the solution that fixed the problem on your side. I am sure it will be helpful to the other users in the Forum.

Regards,

Neli

Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or