I have a scenario where the grid contains a small subset of the fields in a table. When I export to excel, I want to include the extra fields. But there are so many extra fields, and the export is used infrequently, that I don't want the overhead of always including them as hidden columns. What I'd like to do is construct the excel file on the server, and feed it back to the client. I have the grid set up to use the server proxy for the excel export as follows:
@(Html.Kendo().Grid<InstID2.Models.Institution>()
.Name("grdInstitutions")
.ClientDetailTemplateId("client-template")
.Pageable()
.Sortable()
.Filterable()
.ToolBar(t => t.Excel())
.Excel(excel => excel
.FileName("Kendo UI Grid Export.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Default"))
.ForceProxy(true)
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Institution_Read", "Default"))
)
)
)
And I have the server proxy action as follows:
public ActionResult Excel_Export_Save(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
So I have 2 questions:
1. To construct the excel file on the server, the server needs to know the current grid filters that are applied. Is there a way to pass the current filters in as a parameter to the ProxyURL? I've tried a few variations using a javascript function, but nothing has worked so far.
2. Since the server will be executing a query and constructing the excel file, the export data passed from the client (the "base64" parameter above) is not needed. Is there a way to make the client skip creating and sending the export data to the server? This is a minor issue as the parameter can simply be ignored. But it would improve performance if the client could skip that step since it is not needed.
Thanks,
Ray