This is a migrated thread and some comments may be shown as answers.

How to display Header row above column rows when exporting to CSV

1 Answer 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 16 Aug 2016, 02:11 PM

I am using a RadGrid to display information and allowing export to CSV option.  I would like to be able to add some additional 'static' information in the first row of the exported CSV file..

i.e.

(ROW 1) - STATIC TITLE

(ROW 2) - Column Header 1, Column Header 2, Column Header 3..etc
(ROW 3 -X) Column Data 1, Column Data 2, Column Data 3..etc 

I have research multi-header/grouping solution, onrgidExporting solution, insertRow - but I am not able to achieve what I am attempting. 

Sample of my grid

<telerik:RadGrid ID="rgTAS" Width="100%"
 AllowSorting="false"
 AllowPaging="false"
 AllowFilteringByColumn="false"
 ViewStateMode="Enabled"
 OnItemDataBound="rgTAS_ItemDataBound"
 AllowMultiRowSelection="false" runat="server"
        OnGridExporting="rgTAS_onExporting"
 GridLines="None">
 <MasterTableView Width="100%" AutoGenerateColumns="false" CommandItemDisplay="None"
            ShowFooter="false" ShowHeader="true"
             >
 <Columns>
               <telerik:GridBoundColumn DataField="cc" HeaderText="CC"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="country_na" HeaderText="COUNTRY"  ></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="track" HeaderText="TRACK"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="ia" HeaderText="IA" ></telerik:GridBoundColumn>
            </Columns>
            </MasterTableView>
        </telerik:RadGrid>

 

 

 

Please assist...

 

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 19 Aug 2016, 08:05 AM
Hello Robert,

I already answered your support ticket with the same requirement but I will copy my reply here as well if some other customers have a similar requirement.

A possible solution is to insert the additional information in the ExportOuput directly. For this purpose you need to hook OnGridExporting event handler and modify the export output. Please check out the following code snippet.
Copy Code
protected void RadGrid1_GridExporting(object sender, Telerik.Web.UI.GridExportingArgs e)
{
    e.ExportOutput = e.ExportOutput.Insert(0, "\"Title\"\r\n");
}


Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or