This is a migrated thread and some comments may be shown as answers.

Grid Export how to trigger export programaticaly

3 Answers 1267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ross B.
Top achievements
Rank 1
Ross B. asked on 06 Feb 2015, 03:53 PM
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

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 09 Feb 2015, 02:45 PM

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!
 
0
Ronald
Top achievements
Rank 1
answered on 14 Jan 2021, 05:05 AM
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 
0
Georgi Denchev
Telerik team
answered on 15 Jan 2021, 11:41 AM

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/.

Tags
Grid
Asked by
Ross B.
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Ronald
Top achievements
Rank 1
Georgi Denchev
Telerik team
Share this question
or