Unplanned
Last Updated: 31 Jul 2024 08:30 by ADMIN
Nitesh
Created on: 02 May 2022 12:08
Category: Grid
Type: Feature Request
44
Ability to customize export options from methods

The feature request is to be able to customize the GridCsvExportOptions and GridExcelExportOptions from the API methods -

  • ExportToExcelAsync
  • ExportToCsvAsync
  • SaveAsExcelFileAsync
  • SaveAsCsvFileAsync

It will be useful to be able to customize the columns and data to be exported.

===

Telerik edit:

A possible workaround is to click the built-in Grid export buttons with JavaScript. With this approach, you will be able to use the built-in export options and events. Here is a REPL example.

3 comments
ADMIN
Dimo
Posted on: 31 Jul 2024 08:30

Hello Nitesh,

I see your point and we are discussing the scope of this task now.

Regards,
Dimo
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

Nitesh
Posted on: 24 Jul 2024 14:56

Hi Stamo,

 

Any basic functionality i would still expect from telerik grid to provide out of the box like choose which columns from the binded grid list to export.

its a additional effort and training or knowledge which has to be keep on passing to next generation to make them understand why and how certain things are going to work if they need to replicate same in any other projects.

 

I am not expecting very advanced scenarios to be supported, but atleast just a minimum scenario which can be achieved out of the box will be good.

ADMIN
Stamo Gochev
Posted on: 24 Jul 2024 12:55

Hi,

After inspecting the request, it turns out that exposing additional export options might be useful for some concrete basic scenarios, but covering more general scenarios (read below) will be hard to configure by the developer.

For example, if there is an option to configure which columns and data should be exported, then the Telerik Blazor Grid component will not be necessary - in fact, this functionality can be achieved even outside of the Blazor framework as the exported columns and data may not be even present in the Grid - they can be any other columns and data.

Suppose that there is some kind of a helper class that allows exporting any data to an Excel file:

var exportedData = TelerikBlazorExportHelper.ExportToExcel(new TelerikExcelExportOptions() 
{ 
  FileName = "excel-export.xslx"
  Columns = new List<ColumnDescriptor>() 
  { 
    new ColumnDescriptor()
    {    
      Field = "ProductName" 
      ...
    }
  ...
  },
  Data = ...
})

In addition, more complex scenarios with the Grid will require passing additional arguments that are not trivial for the developer to configure - consider a grouping scenario, where aggregates should be calculated for the given data set, their names should be localized, etc.

Another example is multi-column headers, where the developer will need to calculate the offsets of the parent and child columns manually. If the end user reorders or shows/hides certain columns, this will require recalculating the multi-column headers.

For now, certain customizations can be achieved using the "OnBeforeExport" events, while providing export for any data and columns seems more suitable for a Knowledge base example, where a custom button is added to the toolbar of the Grid and uses a utility like "TelerikBlazorExportHelper" (from the above code snippet) to export a specific set of data and columns. The code will be similar to https://demos.telerik.com/blazor-ui/spreadstreamprocessing/overview with some improvements around the helper.

Depending on your feedback, we can prepare such an example.

 

Regards,
Stamo Gochev
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024