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:
@(Html.Kendo().Grid<Services>
()
.Name("gridMain")
.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
.FileName("ABT_Services.xlsx")
.Filterable(true)
)
.DataSource(dataSource =>
dataSource
.WebApi()
.PageSize(Model.GridPageSize)
.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.