ExportToCSV - Retain users' custom column sorting?

1 Answer 13 Views
GridView
Brandon
Top achievements
Rank 1
Brandon asked on 30 Apr 2024, 07:44 PM
When exporting data from a RadGridView to a .csv file using the ExportToCSV class, I'd like the resulting .csv file to be sorted to match what the users have on their grid. For example, if a user were to drag a column on the grid to the far left, I'd expect that column to appear first in the .csv file after exporting. Is there a simple way to accomplish this?

Thanks in advance!

1 Answer, 1 is accepted

Sort by
1
Dinko | Tech Support Engineer
Telerik team
answered on 03 May 2024, 12:36 PM

Hi Brandon,

The ExportToCSV class is an old mechanism for exporting the control to csv. It is better to use the GridViewSpreadExport functionality which exposes a way to export the control to different formats: xlsx, csv, pdf and txt.  GridViewSpreadExport utilizes our RadSpreadProcessing library which is way more feature-rich and exposes different ways to manipulate the exported data.

Now I have tested this with the GridViewSpreadExport and the column order is respected when exporting the control to a CSV file. You can find my test project attached to this reply. I hope that my reply is helpful.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Brandon
Top achievements
Rank 1
commented on 07 May 2024, 05:53 PM

Thanks for the help and the example! We've got it working in our project.
Tags
GridView
Asked by
Brandon
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or