Last Updated: 28 Jan 2020 10:43 by ADMIN
Created on: 21 Jan 2020 18:36
Category: UI for ASP.NET Core
Type: Feature Request
Grid Excel Export - Configure which Columns Get Exported

I am looking for an extension to the Grid Columns fluent api that adds .Exportable(true or false).  Exportable(true) would be the default and indicate that this column does get exported when exporting to Excel (or PDF).  Exportable(false) would indicate that the column does NOT get exported.

Imagine the following Grid Definition:

    .Columns(columns =>
        columns.Bound(p => p.ServiceId).ClientTemplateId("rowNumTemplate").Title("Row").Width(50);
        //columns.Bound(p => p.ServiceId).ClientTemplateId("cmdsTemplate").Title("Cmds").Width(125).Media("(min-width: 768px)");
        columns.Bound(p => p.ServiceCode).Media("(min-width: 768px)");
        columns.Bound(p => p.ServiceId).ClientTemplateId("xsTemplate").Title("Service / Desc / Code").Media("(max-width: 768px)");
        columns.Bound(p => p.ServiceId).ClientTemplateId("serviceTemplate").Title("Service / Desc").Media("(max-width: 992px) and (min-width: 768px)");
        columns.Bound(p => p.ServiceName).Media("(min-width: 992px)");
        columns.Bound(p => p.ServiceDescription).Media("(min-width: 992px)");
        columns.Bound(p => p.ServiceActive).ClientTemplateId("activeTemplate").Width(60).Media("(min-width: 768px)");
        columns.Bound(p => p.ServiceId).ClientTemplateId("btnsTemplate").Title("View/Edit/Del").Width(150);
        //columns.Bound(p => p.ServiceId).ClientTemplateId("xsCmdsTemplate").Title("Cmds").Media("(max-width: 768px)");
    .Scrollable(scrollable => scrollable.Endless(true))
    .Pageable(p => p.Numeric(false).PreviousNext(false))
    .ToolBar(t => t.Search())
    .Search(s => { s.Field(c => c.ServiceCode); s.Field(c => c.ServiceName); s.Field(c => c.ServiceDescription); })
    .Resizable(resize => resize.Columns(true))
	.ToolBar(t => t.Excel().Text("Excel"))
    .Excel(excel => excel
    .DataSource(dataSource =>
    .Model(model =>
        model.Id(p => p.ServiceId);
    .Events(events => events.Error("errorHandler").RequestEnd("gridMainRequestEnd"))
    .Read(read => read.Action("Get", "Services"))

What I would like to do is define a column like the following:

        columns.Bound(p => p.ServiceId).ClientTemplateId("rowNumTemplate").Title("Row").Width(50).Exportable(false);

In the case above, the "Row" column would not be Exported to Excel.

If you take a closer look at the Columns definition above you will see that the configuration is implemented to support responsive page sizing.  Because the current implementation of Export to Excel does not allow an Exportable(true/false), I get these columns that I don't want in the exported Excel.

Although there appear to be workarounds (like keeping a second hidden grid -- a poor solution at best), none would be as useful to a Developer as defining an Exportable(true/false) as part of the Column configuration.

Thanks for considering my request.

1 comment
Veselin Tsvetanov
Posted on: 28 Jan 2020 10:43

Hello Dennis,

Thank you for the appropriate suggestion and for the detailed explanation of the use case. I have just approved your Feature request. We will keep an eye on this item and on the discussion here. If the suggested gains popularity among the community, we will plan the implementation of that column option accordingly.

Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.