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

Dynamically set export filename

1 Answer 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 08 Sep 2017, 09:46 PM
In this example, the filename is hardcoded.  Is it possible to dynamically change the filename? For example add current date/time.

1 Answer, 1 is accepted

Sort by
0
Accepted
Preslav
Telerik team
answered on 12 Sep 2017, 03:13 PM
Hi Erik,

To achieve the desired behavior, handle the excelExport event of the Grid. In the event handler, change the e.workbook.fileName to the desired string.
For example, the code could look like:

function onEexcelExport: (e) {
    var date = new Date();
    var dateName = kendo.toString(date, "g");
    var fileName = "myExcelName " + dateName;
     
    e.workbook.fileName = fileName;
};

For a runnable example, check this Dojo: https://dojo.telerik.com/UFAMor


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or