Kendo Grid :TypeError: $(...).saveAsExcel is not a function
saveAsExcel is not working and is throwing error.Below is my code:
jquery files included:
Kenod Grid Export Excel
@(Html.Kendo().Grid() .Name("grid").NoRecords("No Records Found(s)").Excel(o => o.AllPages(true).FileName("xyz.xls")) .Columns(columns => { columns.Bound(c => c.FirstName). ClientTemplate("#= FirstName #") .Width(150).Title("First Name"); columns.Bound(c => c.Email).Width(150).Filterable(false).Title("Email"); ; columns.Bound(c => c.Phone).Width(150).Filterable(false).Title("Phone"); ; columns.Bound(c => c.StateName).Width(150).Filterable(false).Title("State"); ; columns.Bound(c => c.Stars).Width(150).Filterable(false).Title("Stars"); ; columns.Bound(c => c.ContactsProfiled).Width(150).Filterable(false).Title("Contacts Profiled"); ; columns.Bound(c => c.Leadsregistered).Width(150).Filterable(false).Title("Leads Registered"); ; columns.Bound(c => c.ContestWon).Width(150).Filterable(false).Title("ContestWon"); ; columns.Bound(c => c.UserLastActivity).Width(150).Filterable(false).Title("Last Activity"); ; columns.Bound(c => c.CreatedOn).Width(150).Title("Created On").Format("{0:MM/dd/yyyy }"); }) .ToolBar(toolBar => toolBar. Template(@)) .Resizable(resizing => resizing.Columns(true)) .Reorderable(reorder => reorder.Columns(true)) .HtmlAttributes(new { style = "height: 650px;" }) .Scrollable(scrollable => scrollable.Virtual(true)) .Sortable() .Pageable(pageable => pageable .Refresh(true) .PageSizes(true) .PreviousNext(true) .ButtonCount(5) ) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("WealthWizard_Read", "Dashboard").Data("GetFilter")) .PageSize(50) ))
Function $('#button').click(function () { var gridview = $("#grid").data("kendoGrid");
gridview.saveAsExcel();
});
Make sure you have the right version of javascriot files for kendo excel export. As of the Kendo UI Q3 2014 (2014.3.1119) release, the Grid widget provides a built-in Excel export functionality.
链接地址: http://www.djcxy.com/p/70444.html