Custom Export...

2 posts, 0 answers
  1. Raymond
    Raymond avatar
    24 posts
    Member since:
    Jul 2014

    Posted 03 Aug 2016 Link to this post

    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:

        .ToolBar(t => t.Excel())
        .Excel(excel => excel
            .FileName("Kendo UI Grid Export.xlsx")
            .ProxyURL(Url.Action("Excel_Export_Save", "Default"))
        .DataSource(dataSource => dataSource
            .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.





  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1968 posts

    Posted 05 Aug 2016 Link to this post

    Hello Raymond,

    My suggestion is to review the Server-side Excel export project. It demonstrates how to export the Kendo UI Grid data as an Excel document on the server side. Main advantage of server-side export is that it allows the developer full control over the final output.

    Boyan Dimitrov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top