GridExcelExportColumn Position

0 Answers 105 Views
Grid
Israel
Top achievements
Rank 1
Israel asked on 05 Sep 2023, 01:37 PM | edited on 05 Sep 2023, 04:43 PM

Hello forum, does anyone know how can I get the position of GridExcelExportColumn? I need to insert a few Hidden Columns in a specific place on grid's OnAfterExport Event is this the way to go?

 

GridExcelExportColumn afterThisColumnIWantToInsertHiddenColumns = args.Columns.Find(x => x.Field == nameof(Model.Property));

var index = args.Columns.IndexOf(afterThisColumnIWantToInsertHiddenColumns) args.Columns.InsertRange(index , hiddenColumns);


Hristian Stefanov
Telerik team
commented on 08 Sep 2023, 12:01 PM

Hi Israel,

From the provided information, I understand that your main goal is to add hidden columns at a specific place that will appear in the exported Grid file.

To achieve this, the way I recommend is to use the OnBeforeExport event instead of OnAfterExport. By doing so, you can easily insert the desired hidden columns at whatever index you need to see it in the exported file.

To illustrate this concept, I have prepared an example for you in this REPL link. Please run and test it to determine whether the result is what you are looking for.

If I missed addressing something or I misunderstood the general idea, I remain at your disposal to assist further.

Kind Regards,

Hristian

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Israel
Top achievements
Rank 1
Share this question
or