
Hi
I would like to use SaveAsPdf export in my application. I need to place the export button somewhere other than on the tollbar.
Is there a way to make such export in the background without auto clicking through each page in the gui, like in the case of using toolbar: ["pdf"]?
It must have the ability to export all pages and auto paper size.
Example:
1 Answer, 1 is accepted
Hello, Krzysztof,
From what I can see in the provided example, you have achieved the requirement as I understand it - you are using a custom button to export all of the Grid pages. Could you please let me know if I am missing something from the requirement?
Looking forward to your reply.
Regards,
Martin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hello Martin
Thanks for your reply.
Yes, I use custom button because I have to place it under the grid. Additionally, the requirement is to export all pages and set paperSize to auto because the solution will be used in a grid that has a different number of columns in different scenarios and setting a specific page size causes it to look bad in PDF.
Regards
Hello, Krzysztof,
Thank you for the additional information, but it still seems to be that you have managed to achieve the requirement by yourself in the Dojo example you provided. All of the Grid records are being exported, and the paperSize is set to auto. Could you please let me know what is the issue you are experiencing with in the example you provided?
Hi
Yes, export works correctly, it export what I want. The problem is that on the gui the user sees that the pages change during this export (in this case it happens very quickly). There is no such thing when we use export to pdf from the toolbar (toolbar: ["pdf"]).
I hope I explained the problem.
Updated example:
https://dojo.telerik.com/buemsOwD
Hello,
Thank you for the additional details. I have modified the example with some of the internal logic that is used for the default export button. Let me know how that works for you.
Hello.
It works as I needed.
Thank you very much.
I have noticed one problem and there is a risk that users may also see it.
The thing is that exporting my grid may take a few seconds. The user can open a small browser window and during the export enlarge it and then you will see two grids. The blocked one and the one underneath where the export is taking place.
Is there any way to solve this?
Hello, Krzysztof,
I am not sure how to observe the behaviour you have stumbled upon. Could you please provide the steps I need to make, and modify the Dojo example if necessary? I will then be happy to investigate for a solution. Thank you in advance for the cooperation.
Hi Martin
I added a timeout to the example https://dojo.telerik.com/UBdrxGPa
To reproduce the problem, you need to run the example in a small window and after starting the export enlarge it. After that you should get an effect like the one I attached on the screen.
Hi Krzysztof,
The internal logic that Martin added is not supported for eternal usage and as you can see, it might lead to unexpected side effects.
I can suggest another approach to avoiding the traversal of pages.
- Temporarily load all data
- Export the Grid
- Return the page size to the previous one.
$("#export").click(function(e) {
var grid = $("#grid").data("kendoGrid");
let pageSize = grid.dataSource.pageSize();
console.log(pageSize)
grid.dataSource.pageSize(grid.dataSource.total());
// Fetch all data without changing pages
grid.dataSource.fetch().then(function () {
grid.saveAsPDF();
setTimeout(function() {
grid.dataSource.pageSize(pageSize);
}, 100)
});
});
Dojo demo: https://dojo.telerik.com/LmMURdVV
Regards,
Nikolay