I am using Kendo grid for MVC 4.0. I have the latest DLL 2015.1.318.440
. I am including jszip.js
. I copied and pasted the code from the example:
.ToolBar(tools => tools.Excel())
.Excel(excel => excel.FileName("Enrollments.xlsx"))
It does nothing. The button changes color and that's it. I don't get any errors when I try it. It just doesn't do anything. I am not using a proxy server. I am running this in Chrome latest version.
The grid
@(Html.Kendo().Grid<Trawick.Agents.Models.EnrollmentPolicy>()
.Name("grid")
.ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("Enrollments.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Enrollments"))
)
.Columns(columns =>
{
columns.Bound(p => p.enrollment_date)
})
.Pageable()
.Groupable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Enrollments_Read", "Enrollments")))
)
The controller
[HttpPost]
public ActionResult Excel_Export_Save(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
public ActionResult Enrollments_Read([DataSourceRequest]DataSourceRequest request, int? id)
{
string sql = "SELECT * FROM EnrollmentPolicy ";
sql += SearchParams.SetSearch(this);
return Json(GetEnrollments(sql).ToDataSourceResult(request));
}
Bundle file including jszip
bundles.Add(new ScriptBundle("~/js/kendo")
.Include("~/Scripts/jszip.js")
.Include("~/Scripts/kendo.all.min.js")
.Include("~/Scripts/kendo.aspnetmvc.min.js"));
bundles.Add(new ScriptBundle("~/js/kendo")
.Include("~/Scripts/kendo.all.min.js")
.Include("~/Scripts/kendo.aspnetmvc.min.js")
.Include("~/Scripts/jszip.js"));
This was the issue.jszip has to be included AFTER the kendo scripts (this is the opposite of what the documentation says).