This is a migrated thread and some comments may be shown as answers.
Export to PDF, multiple reports generated
5 Answers 15 Views
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 09 Oct 2018, 01:19 PM

Hello,

I have a simple grid that works fine. MVC 5 project. jquery read only grid. I added one line only to the grid definition - "toolbar: ["pdf"],":

                        function createHoldingsTable() {
                            $("#gridHoldings").kendoGrid({
                                toolbar: ["pdf"],
                                height: 600,
                                resizable: true,
                                sortable: true,
                                scrollable: true,
                                dataSource: {
                                    data: holdingsData

The holdingsData is json array that populated by drop-down control on the web page. When I click on PDF button then one PDF report generated per a click and that's is expected. Close it and click again - one PDF generated with the same content. If I choose another value in the drop-down box, the grid updated fine and displays new content. PDF button will now generate two PDFs, one have old (for first drop-down value) and another with new content. Changing the drop-down value third time will produce three reports.

I've checked the javascripts and they included ones:

<script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script><script src="/Scripts/jquery.validate.js"></script>

<script src="/Scripts/jquery.validate.unobtrusive.js"></script>

<script src="/Scripts/kendo/2018.2.516/kendo.all.min.js"></script>

<script src="/Scripts/kendo/2018.2.516/kendo.aspnetmvc.min.js"></script>

<script src="/Scripts/modernizr-2.8.3.js"></script>

What I am doing wrong? Where my problem could be?

Thanks.

 

 

5 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 11 Oct 2018, 10:57 AM
Hello Andrey,

Could you confirm if you run the createHoldingsTable method on each DropDownList change? This would result in creating multiple instances of the Grid and maybe this is the reason for the multiple files export.

In general, you should only update the Grid data when a new item is selected in the DropDownList:
$("#gridHoldings").data("kendoGrid").dataSource.data(holdingsData);

If the problem persists, please share the code that you run on DropDownList selection change.

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Andrey
Top achievements
Rank 1
answered on 11 Oct 2018, 04:40 PM

Hello Tsvetina,

yes, it was the reason. Is there any way to figure out if a kendo grid had already created (exists)? Otherwise I have create a global variable in JavaScript.

Thanks!

0
Andrey
Top achievements
Rank 1
answered on 11 Oct 2018, 05:39 PM

Is there any way to destroy/disposal an existing grid?

Thanks!

0
Andrey
Top achievements
Rank 1
answered on 12 Oct 2018, 02:00 PM

Hi,

one more question. The export to PDF works fine locally but after publishing to IIS it goes through and displays the progress bar but then nothing happened. The progress bar is on IE and pdf pop up does not displayed. In is very small pdf - 5 rows in a grid.

0
Tsvetina
Telerik team
answered on 15 Oct 2018, 12:02 PM
Hi Andrey,

With regard to checking for Grid existence, you can do something like this:
if($("#grid").data("kendoGrid")){
    // grid exists, only set data
}
else {
    // grid does not exist, create it
}

If you need to destroy the Grid, follow the instructions here: Destroy Widgets Manually.

If you need to just change a widget's properties, use setOptions.

As for the failing export in production, did you check for any JS errors during the export? Since the entire logic runs on the client, if it fails somewhere, there should be a JS error thrown.

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