Skip to content

Instantly share code, notes, and snippets.

@lohithgn
Created January 28, 2015 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lohithgn/a3d8f150ea6124ccf311 to your computer and use it in GitHub Desktop.
Save lohithgn/a3d8f150ea6124ccf311 to your computer and use it in GitHub Desktop.
Kendo UI Grid with external buttons to export
<div id="grid"></div>
<br>
<button class="k-button k-primary" id="btnExcelExport">Export to Excel</button>
<button class="k-button k-primary" id="btnPdfExport">Export to PDF</button>
<script>
$("#btnExcelExport").kendoButton({
click:function(){
$("#grid").getKendoGrid().saveAsExcel();
}
});
$("#btnPdfExport").kendoButton({
click:function(){
$("#grid").getKendoGrid().saveAsPDF();
}
});
$("#grid").kendoGrid({
excel:{
fileName:"Northwind Product List.xlsx",
allPages:true,
filterable:true
},
pdf:{
author:"Lohith G N",
creator:"Telerik India",
date:new Date(),
fileName:"Northwind Product List.pdf",
keywords:"northwind products",
landscape:false,
margin:{
left: 10,
right: "10pt",
top: "10mm",
bottom: "1in"
},
paperSize:"A4",
subject:"Northwind Products",
title:"Northwind Products"
},
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Products"
},
pageSize: 10
},
sortable: true,
pageable: true,
columns: [
{ width: 300, field: "ProductName", title: "Product Name" },
{ field: "UnitsOnOrder", title: "Units On Order" },
{ field: "UnitsInStock", title: "Units In Stock" }
]
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment