New to Kendo UI for jQuery? Start a free 30-day trial
Customize the Pdf Export Filename of the Grid by Adding Current Date and Time
Environment
Product | Progress® Kendo UI® Grid for jQuery |
Description
How can I add the current date and time to the Pdf export filename of the Grid?
Solution
-
Use the
pdfExport
event to access the Grid options. -
With the help of the
kendo.toString()
method or another way to format the date, concatenate the date to the filename:
js
pdfExport: function(e) {
e.sender.options.pdf.fileName = kendo.toString(new Date, "dd/MM/yyyy HH:mm") + " Grid.pdf";
}
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
toolbar: ["pdf"],
columns: [
{ field: "name" }
],
pdfExport: function(e) {
e.sender.options.pdf.fileName = kendo.toString(new Date, "dd/MM/yyyy HH:mm") + " Grid.pdf";
},
dataSource: [
{ name: "Jane Doe"},
{ name: "John Doe"}
]
});
var grid = $("#grid").data("kendoGrid");
</script>