Export to PDF, multiple reports generated

6 posts, 1 answers
  1. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 09 Oct 2018 Link to this post

    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.

     

     

  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 11 Oct 2018 Link to this post

    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.
  3. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 11 Oct 2018 in reply to Tsvetina Link to this post

    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!

  4. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 11 Oct 2018 in reply to Andrey Link to this post

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

    Thanks!

  5. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 12 Oct 2018 in reply to Andrey Link to this post

    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.

  6. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 15 Oct 2018 Link to this post

    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.
Back to Top