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

Multi-column headers - Export to CSV missing column names

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Katy
Top achievements
Rank 1
Katy asked on 19 Dec 2013, 06:49 PM
I'm using Version: 2012.1.215.35 and I'm trying to create a grid that has multi-column headers that span 2 columns. I want to be able to export this grid to CSV and I'm running into problems. 
  • The column names are missing
  • The values are all together without being separated by commas.  (e.g.  "25 25%")

Here is my front end code:

<telerik:GridTemplateColumn ItemStyle-CssClass="rollupItem" HeaderStyle-CssClass="rgHeader rollupHeader" UniqueName="TemplateColumn">
    <HeaderTemplate>
        <table id="ContactTableHeader" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr class="rollupTopHeader">
                <td colspan="2" align="center">
                    <asp:Label ID="hasReceived" runat="server" Text='Has Received Prior'></asp:Label>                                                       
                </td>                                                   
            </tr>
            <tr class="rollupBottomHeader">
                <td width="16%" align="center">
                    <asp:Label ID="hasReceivedTreatmentCountLabel" runat="server" Text='Count'></asp:Label>
                </td>
                <td width="16%" align="center">
                    <asp:Label ID="hasReceivedTreatmentPercentLabel" runat="server" Text='Percent'></asp:Label>
                </td>                                                                                                                                                         
            </tr>
        </table>   
    </HeaderTemplate>
    <ItemTemplate>
        <table id="ContactRelationshipTable" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr class="rollupData">
                <td width="16%">
                    <asp:Label ID="hasReceivedTreatmentCount" runat="server" Text='<%# Eval("HasReceivedTreatmentCount") %>'></asp:Label>                                                       
                </td>
                <td width="16%">
                    <asp:Label ID="hasReceivedTreatmentPercent" runat="server" Text='<%# Eval("HasReceivedTreatmentPercent") %>'></asp:Label>                                                                                                               
                </td>                                                                                                   
            </tr>
        </table>       
    </ItemTemplate>                                  
</telerik:GridTemplateColumn>

Back end code:
protected void ExportToCSVButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
    try
    {
        RollupReportRadGrid.ExportSettings.ExportOnlyData = false;
        RollupReportRadGrid.MasterTableView.ExportToCSV();
    }
    catch (Exception ex)
    {
        GenericException.HandleException(ex);
        Response.Redirect("~/GenericError.aspx");
    }
}

Can someone help with this problem? 

Thanks,
Katy Maffei

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Dec 2013, 07:47 AM
Hi Katy,

Since CSV is text-based format it doesn't support images or complex structures like tables. You can try Export To Excel if you want to use table structures or please go through this demo to use MultiColumn Headers which can be used for Export to CSV.

Thanks,
Princy
Tags
Grid
Asked by
Katy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or