Grid Export how to trigger export programaticaly

4 posts, 0 answers
  1. Ross B.
    Ross B. avatar
    21 posts
    Member since:
    Dec 2011

    Posted 06 Feb 2015 Link to this post

    Greetings,

    How can I trigger a grid to export to pdf or excel manually. What functions are there to $('#Grid').Export() ? 

    Have a good day
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 09 Feb 2015 Link to this post

    Hello Ross,

    You could use the built in saveAsExcel and saveAsPDF methods of the Grid API.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Ronald
    Ronald avatar
    1 posts
    Member since:
    Nov 2020

    Posted 13 Jan in reply to Dimiter Madjarov Link to this post

    How can you achieve this with out it also force saving the file as using e.preventDefault() does not work in stopping the file to be saved 
  4. Georgi Denchev
    Admin
    Georgi Denchev avatar
    110 posts

    Posted 15 Jan Link to this post

    Hello Ronald,

    You can prevent the default behavior of the Excel Export functionality through the excelExport event.

    <button id="export">Export to Excel</button>
    <div id="grid"></div>
    <script>
    $("#grid").kendoGrid({
      columns: [
        { field: "name" },
        { field: "age" }
      ],
      dataSource: [
          { name: "Jane Doe", age: 30 },
          { name: "John Doe", age: 33 }
      ],
      excelExport: function(e) {
        e.preventDefault(); // Prevent the export event.
      }
    });
    $("#export").click(function(e) {
        var grid = $("#grid").data("kendoGrid");
        grid.saveAsExcel();
    });
    </script>

    Best Regards,
    Georgi Denchev
    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/.

Back to Top