Skip to main content

Posts

Showing posts from January, 2014

Exporting Kendo UI GRID to Excel with Java

This is a simple method of creating an Excel export function on your Kendo UI grid with a Java EE server. JS function to trigger Excel export In your web-page with the grid - insert this JS function. You should create a button or similar that calls this when you want to perform the export from the UI. function exportGridToExcel() { var grid = $("#grid").data("kendoGrid"); var currentPage = grid.dataSource.page(); var allPages = new Array(); for(var n=1;n<=grid.dataSource.totalPages();n++) { grid.dataSource.page(n); var view = grid.dataSource.view(); for(var x=0;x<view.length;x++) { allPages.push(view[x]); } } $("#excelExportGridData").val(JSON.stringify({"rows": allPages, "cols": grid.columns})); $("#exportToExcelForm").submit(); grid.dataSource.page(currentPage); } Hidden form and iframe You also nee