New to Kendo UI for jQuery? Download free 30-day trial

Customize the Pdf Export Filename of the Grid by Adding Current Date and Time

Environment

Product Progress Kendo UI Grid

Description

How can I add the current date and time to the Pdf export filename of the Grid?

Solution

  1. Use the pdfExport event to access the Grid options.

  2. With the help of the kendo.toString() method or another way to format the date, concatenate the date to the filename:

    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>
In this article
Not finding the help you need? Improve this article