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

2 posts, 0 answers
  1. Robert
    Robert avatar
    4 posts
    Member since:
    Sep 2012

    Posted 16 Aug Link to this post

    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..



    (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%"
     AllowMultiRowSelection="false" runat="server"
     <MasterTableView Width="100%" AutoGenerateColumns="false" CommandItemDisplay="None"
                ShowFooter="false" ShowHeader="true"
                   <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>




    Please assist...


  2. Kostadin
    Kostadin avatar
    1711 posts

    Posted 19 Aug Link to this post

    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");

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top