I'm testing the grid for an almost certain purchase, and I've tried to export it to both PDF and XLS. With Excel it was almost straight forward, but when I try to follow the steps presented on the demo (http://demos.telerik.com/aspnet-mvc/Beta/grid/pdf-export) it does not work. When I click on the export button, the progress bar loads and when it finishes nothing happens, the action never gets to be executed.
This is my view:
@model IEnumerable<ViewModels.TestViewModel>
@{
ViewBag.Title = "Tests KendoUI";
}
<script src="~/Scripts/lib/jszip.min.js" type="text/javascript"></script>
<script src="~/Scripts/lib/pako.min.js" type="text/javascript"></script>
<style>
/*
Use the DejaVu Sans font for display and embedding in the PDF file.
The standard PDF fonts have no support for Unicode characters.
*/
.k-grid {
font-family: "DejaVu Sans", "Arial", sans-serif;
}
/* Hide the Grid header and pager during export */
.k-pdf-export .k-grid-toolbar,
.k-pdf-export .k-pager-wrap,
.k-pdf-export a.k-button.k-button-icontext,
.k-pdf-export .k-filter-row,
.k-pdf-export .k-grouping-header,
.k-pdf-export .k-grid tr td:last-child {
display: none !important;
}
</style>
@(Html.Kendo().Grid(Model)
.Name("grid")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Products_Read", "Home"))
.Aggregates(aggregates => aggregates.Add(p => p.oper_monto).Sum())
)
.Columns(columns =>
{
columns.Bound(p => p.oper_numero).Hidden(true);
columns.Bound(p => p.oper_monto).ClientFooterTemplate("Total: #=sum#");
columns.Bound(p => p.cpto_codigo);
})
.Excel(excel => excel
.FileName("Reporte.xlsx")
.Filterable(true)
.AllPages(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Home"))
)
.Pdf(pdf => pdf
.AllPages()
.FileName("Reporte.pdf")
.ProxyURL(Url.Action("Pdf_Export_Save", "Home"))
)
.ColumnMenu()
.ToolBar(t => t.Excel().Text("Exportar a Excel"))
.ToolBar(t => t.Pdf().Text("Exportar a PDF"))
.ToolBar(toolBar =>
toolBar.Custom()
.Text("Guardar Preferencias")
.HtmlAttributes(new { id = "save" })
)
.ToolBar(toolBar =>
toolBar.Custom()
.Text("Cargar Preferencias")
.HtmlAttributes(new { id = "load" })
)
.Filterable(ftb => ftb.Mode(GridFilterMode.Menu))
)
<script>
$(function () {
var grid = $("#grid").data("kendoGrid");
$("#save").click(function (e) {
e.preventDefault();
localStorage["kendo-grid-options"] = kendo.stringify(grid.getOptions());
});
$("#load").click(function (e) {
e.preventDefault();
var options = localStorage["kendo-grid-options"];
if (options) {
grid.setOptions(JSON.parse(options));
}
});
});
</script>
And this is my controller action:
[HttpPost]
public ActionResult Pdf_Export_Save(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
Thanks in advance.