Hi everyone, I'm new in Kendo ASP.NET and I would like to see if some one could help me or give me an a guide. Rigth now I'm trying to implement an excel export of a pivotGrid. I already set all the pivotgrid configuration as in Razor as in the controller but when ran it I got the error (ScreenShot Attached).
The following is the configuration of the pivotGrid the View and Controller.
View:
@ModelType IEnumerable(Of TelerikMvcVB.HomeModel)
<link href="@Url.Content("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" />
@* Content-box fixes as per http://docs.telerik.com/kendo-ui/third-party/using-kendo-with-twitter-bootstrap article *@
<link href="@Url.Content("~/Content/box-sizing-fixes.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/2018.2.620/styles/kendo.common-bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/2018.2.620/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/2018.2.620/styles/kendo.bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://kendo.cdn.telerik.com/2018.2.620/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.2.620/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.2.620/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.2.620/js/kendo.aspnetmvc.min.js"></script>
<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
<script src="~/Scripts/kendo/jszip.min.js"></script>
<div>
<div style="margin-top:-2%">
<h2>Kendo PivotGrid - Razor</h2>
</div>
<button id="export" class="k-button k-button-icontext hidden-on-narrow"><span class="k-icon k-i-excel"></span>Exportar Excel</button>
<div class="responsive-message"></div>
<div>
@(Html.Kendo().PivotConfigurator().Name("configurator") _
.HtmlAttributes(New With {.class = "hidden-on-narrow"}) _
.Filterable(True) _
.Sortable() _
.Height(570)
)
@(Html.Kendo().PivotGrid(Of HomeModel)() _
.Name("pivotgrid") _
.Excel(Function(excel) excel _
.FileName("PruebaExcelRazor.xlsx") _
.ForceProxy(Url.Action("Excel_Export_Save", "Home"))) _
.HtmlAttributes(New With {.class = "hidden-on-narrow"}) _
.Sortable() _
.Configurator("#configurator") _
.ColumnWidth(120) _
.Height(570) _
.BindTo(Model) _
.DataSource(Function(dataSource) dataSource _
.Ajax() _
.Schema(Function(schema) schema _
.Cube(Function(cube) cube _
.Dimensions(Function(dimensions) _
{
dimensions.Add(Function(model) model._nombre).Caption("Nombre"),
dimensions.Add(Function(model) model._idProductos).Caption("Id Producto"),
dimensions.Add(Function(model) model._precio).Caption("Precio"),
dimensions.Add(Function(model) model._cantidad).Caption("Cantidad")
}) _
.Measures(Function(measures) measures.Add("Contar Productos").Field(Function(model) model._idProducto).AggregateName("Count"))
))))
)
</div>
</div>
@Scripts.Render("~/bundles/bootstrap")
@*@RenderSection("scripts", required:=False)*@
<style>
#pivotgrid {
display: inline-block;
vertical-align: top;
width: 70%;
}
#configurator {
display: inline-block;
vertical-align: top;
}
.hidden-on-narrow {
display: inline-block;
vertical-align: top;
}
</style>
<script>
$(function () {
$("#export").click(function () {
$("#pivotgrid").getKendoPivotGrid().saveAsExcel();
});
});
function onError(e) {
alert("error: " + kendo.stringify(e.errors[0]));
}
</script>
Controller:
Imports System.Runtime.InteropServices
Imports System.Web
Imports Kendo.Mvc.Extensions
Imports Kendo.Mvc.UI
Public Class HomeController
Inherits System.Web.Mvc.Controller
Function Index() As ActionResult
Dim DA As New DataAccess
Dim lstProductos = DA.GetProductList()
Return PartialView("~/Views/Home/Index.vbhtml", lstProductos)
End Function
<HttpGet>
Function Excel_Export() As ActionResult
Return View()
End Function
<HttpPost>
Function Excel_Export_Save(ByVal contentType As String, ByVal base64 As String, ByVal fileName As String) As ActionResult
Try
Dim fileContents = Convert.FromBase64String(base64)
Return File(fileContents, contentType, fileName)
Catch ex As Exception
End Try
End Function
Function ListGetData() As ActionResult
Try
Dim DA As New DataAccess
Dim lstProductos = DA.GetProductList()
Return View("~/Views/Home/Index.vbhtml", lstProductos)
'Return lstProductos
Catch ex As Exception
' Return HttpStatusCodeResult(400, "")
End Try
End Function
End Class
Thanks for any help about the error..I made the code from the example of the web page from the remote binding