I have a pageable and filterable grid which I set up to export to excel using the new Kendo Grid Excel feature. However, even when I set AllPages to be true I only get the first 10 results, no matter what I set the pagesize to. Removing the Pageable attribute gives me the full reults. Anyone else have problems with this?
Here's the setup for my grid.
@(Html.Kendo().Grid(Model.CloudUsage)
.Name("PCloudUsages")
.ToolBar(toolbar =>
{
toolbar.Excel().HtmlAttributes(new { @class = "toolbar-field" });
})
.Columns(columns =>
{
columns.Bound(c => c.ProjectCode).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(c => c.ProjectName).Title("ProjectName").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").ShowOperators(false)));
})
.Pageable(p => p.ButtonCount(5).PageSizes(new int[] { 10, 20, 50, 100 }))
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Sortable()
.Excel(excel => excel.FileName("CloudUsages.xlsx").Filterable(true).ProxyURL(Url.Action("ExportExcel", "Admin")).AllPages(true))
.DataSource(source => source
.Ajax()
.Model(m => m.Id(itm => itm.ProjectName))
.Read(read => read.Action("PCloudUsages_Read", "Admin").Data("GetDates"))
.Sort(sort => sort.Add(itm => itm.ProjectName).Descending())
)
)
And the controller method
public ActionResult ExportExcel(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
Edit: I have noticed that changing the "pageSize" attribute of the datasource changes the number of rows in the excel file. So it seems that it always produces the excel file the size of the Datasource Pagesize, no matter if the AllPages is set to true, or what the pagesize is set to on the grid.
.Excel()
line is not the same name as your listed controller method. – Matt Millican