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

Grid Export Issue with GridTemplateColumn that Contains multiple values

2 Answers 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clint Leonard
Top achievements
Rank 1
Clint Leonard asked on 10 Aug 2010, 06:57 PM
I am attempting to export the grid below and have it look like it does in the screen shot gridscreenshot.jpg (colors and links not important -- just need the data displayed correctly).

I am using GridTemplateColumns, and the item template area is actually four (4) different values as shown in the code below.

The problem is that during the export, these values are all being pushed together like one big number (see gridexport.jpg)

I have been browsing the other grid export related issues but I think this is different than anything else I am seeing and I am unsure how to correct it.

thanks in advance for your help!

Here is the grid I am exporting:

grid aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowCustomPaging="False" AllowMultiRowSelection="False"
    AllowPaging="False" AutoGenerateColumns="False" PageSize="500" OnItemCreated="RadGrid1_ItemCreated"
    BorderColor="Black" BorderStyle="Solid" BorderWidth="1" OnItemDataBound="RadGrid1_ItemDataBound"
    Skin="None" Width="950px" OnItemCommand="RadGrid1_ItemCommand" OnGridExporting="RadGrid1_GridExporting" OnExcelExportCellFormatting="RadGrid1_ExcelExportCellFormatting">
    <ExportSettings IgnorePaging="true" ExportOnlyData="true"  >  
        <Excel Format="Html" />                      
    </ExportSettings>                     
    <%--<PagerStyle  BackColor="White" Mode="Advanced" ShowPagerText="false" Position="Bottom" />--%>
    <MasterTableView AllowCustomSorting="False" DataKeyNames="GroupByID,RowType" EditMode="InPlace">
        <Columns>
            <telerik:GridTemplateColumn UniqueName="GroupByNameTemplate" DataField="GroupByName" HeaderText="Scope Object"
                HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
                ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"
                ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table id="GroupByHeaderTable3" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                Scope Object
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <%# System.Web.UI.DataBinder.Eval(Container.DataItem, "GroupByName") %>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="GroupByTypeTemplate" DataField="GroupByType" HeaderText="Type"
                HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
                ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"
                ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table id="GroupByHeaderTable3" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                Type
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <%# System.Web.UI.DataBinder.Eval(Container.DataItem, "GroupByType")%>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DesignTemplate" HeaderStyle-BorderColor="Black" HeaderText="Design"
                HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="Black"
                ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1" ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table width="100%" id="GroupByHeaderTable5">
                        <tr>
                            <td colspan="4" width="100%" style="text-align: center; border: thin solid #000000;">
                                Design
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" style="text-align: center;">
                                N/A<br />
                                <asp:imagebutton id="imgChart1" title="Chart Design N/A" style="cursor: pointer;" alt="" runat="server" 
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Design" CommandArgument="0" /> 
                                      
                            </td>
                              
                            <td width="25%" style="text-align: center; color: #008000;">
                                Full<br />
                                <asp:imagebutton id="Imagebutton1" title="Chart Design Full Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Design" CommandArgument="1"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #C59F0C";>
                                Partial<br />
                                <asp:imagebutton id="Imagebutton2" title="Chart Design Partial Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Design" CommandArgument="2"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #800000;">
                                None<br />
                                <asp:imagebutton id="Imagebutton3" title="Chart Design No Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Design" CommandArgument="3"/>                                                
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table width="100%" id="GroupByHeaderTable6">
                        <tr>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.DesignNA") %>'
                                    ToolTip="Design N/A" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=DesignNA" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink2" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.DesignFullCredit") %>'
                                    ToolTip="Design Full Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=DesignFullCredit" ForeColor="Green" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink3" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.DesignPartialCredit") %>'
                                    ToolTip="Design Partial Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=DesignPartialCredit" ForeColor="#C59F0C" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink4" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.DesignNoCredit") %>'
                                    ToolTip="Design No Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=DesignNoCredit"  ForeColor="#800000"/>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="EffectivenessTemplate" HeaderStyle-BorderColor="Black" HeaderText="Effectiveness"
                HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="Black"
                ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1" ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table width="100%" id="GroupByHeaderTable7">
                        <tr>
                            <td colspan="4" width="100%" style="text-align: center; border: thin solid #000000;">
                                Effectiveness
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" style="text-align: center;">
                                N/A<br />
                                <asp:imagebutton id="imgE0" title="Chart Effectiveness N/A" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Effectiveness" CommandArgument="0"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #008000;">
                                Full<br />
                                <asp:imagebutton id="imgE1" title="Chart Effectiveness Full Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Effectiveness" CommandArgument="1"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #C59F0C;">
                                Partial<br />
                                <asp:imagebutton id="imgE2" title="Chart Effectiveness Partial Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Effectiveness" CommandArgument="2"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #800000;">
                                None<br />
                                <asp:imagebutton id="imgE3" title="Chart Effectiveness No Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Effectiveness" CommandArgument="3"/>                                                
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table width="100%" id="GroupByHeaderTable8">
                        <tr>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink5" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.EffectivenessNA") %>'
                                    ToolTip="Effectiveness N/A" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=EffectivenessNA" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink6" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.EffectivenessFullCredit") %>'
                                    ToolTip="Effectiveness Full Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=EffectivenessFullCredit" ForeColor="Green"/>
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink7" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.EffectivenessPartialCredit") %>'
                                    ToolTip="Effectiveness Partial Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=EffectivenessPartialCredit" ForeColor="#C59F0C"/>
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink8" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.EffectivenessNoCredit") %>'
                                    ToolTip="Effectiveness No Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=EffectivenessNoCredit" ForeColor="#800000"/>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="OverallTemplate" HeaderStyle-BorderColor="Black" HeaderText="Overall"
                HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="Black"
                ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1" ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table width="100%" id="GroupByHeaderTable9">
                        <tr>
                            <td colspan="4" width="100%" style="text-align: center; border: thin solid #000000;
                                border-collapse: collapse;">
                                Overall
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" style="text-align: center;">
                                N/A<br />
                                <asp:imagebutton id="imgO0" title="Chart Overall N/A" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Overall" CommandArgument="0"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #008000;">
                                Full<br />
                                <asp:imagebutton id="imgO1" title="Chart Overall Full Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Overall" CommandArgument="1"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #C59F0C;">
                                Partial<br />
                                <asp:imagebutton id="imgO2" title="Chart Overall Partial Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Overall" CommandArgument="2"/>                                                
                            </td>
                            <td width="25%" style="text-align: center; color: #800000;">
                                None<br />
                                <asp:imagebutton id="imgO3" title="Chart Overall No Credit" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Overall" CommandArgument="3"/>                                                
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table width="100%" id="GroupByHeaderTable10">
                        <tr>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink9" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.OverallNA") %>'
                                    ToolTip="Overall N/A" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=OverallNA" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink10" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.OverallFullCredit") %>'
                                    ToolTip="Overall Full Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=OverallFullCredit" ForeColor="Green" />
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink11" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.OverallPartialCredit") %>'
                                    ToolTip="Overall Partial Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=OverallPartialCredit" ForeColor="#C59F0C"/>
                            </td>
                            <td width="25%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink12" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.OverallNoCredit") %>'
                                    ToolTip="Overall No Credit" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=OverallNoCredit" ForeColor="#800000"/>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="NoResponseTemplate" HeaderStyle-BorderColor="Black" HeaderText="No Response"
                HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="Black"
                ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1" ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table id="GroupByHeaderTable11" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                No<br />Response<br />
                                <asp:imagebutton id="imgNR" title="Chart No Response" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="No Response"/>                                                
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table id="GroupByHeaderTable12" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink13" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.NoResponse") %>'
                                    ToolTip="No Response" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=NoResponse" />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="TotalControlsTemplate" HeaderStyle-BorderColor="Black" HeaderText="Total Controls"
                HeaderStyle-BackColor="White" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
                ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"
                ItemStyle-BackColor="White">
                <HeaderTemplate>
                    <table id="GroupByHeaderTable13" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                Total<br />Controls<br />
                                <asp:imagebutton id="imgTC" title="Chart Total Controls" style="cursor: pointer;" alt="" runat="server"
                                    ImageUrl="~/images/icons/report-icon.gif" CommandName="Total Controls" />                                                
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table id="GroupByHeaderTable12" width="100%">
                        <tr>
                            <td width="100%" style="text-align: center;">
                                <asp:HyperLink ID="HyperLink14" runat="server" Text='<%# System.Web.UI.DataBinder.Eval(Container, "DataItem.TotalControls") %>'
                                    ToolTip="Total Controls" NavigateUrl="complianceDashboardDetail.aspx?AssessmentID={0}&GroupByName={1}&LinkID={2}&Column=TotalControls" />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn HeaderText="GroupByIDList" DataField="GroupByIDList" Visible="false" />
            <telerik:GridBoundColumn HeaderText="GroupByName" DataField="GroupByName" Visible="false" />
            <telerik:GridBoundColumn HeaderText="ParentRow" DataField="ParentRow" Visible="false" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Attaching a screen shot of the grid (gridscreenshot.jpg)

And the relevant code behind:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = (GridDataItem)e.Item;
        string groupByName = dataItem["GroupbyName"].Text;                
        dataItem["GroupByNameTemplate"].Text = groupByName.Replace("     ", "     ");
        for (int i = 1; i <= 14; i++)
        {           
            HyperLink hypLink = (HyperLink)dataItem.FindControl("HyperLink" + i.ToString());
            hypLink.NavigateUrl = String.Format(hypLink.NavigateUrl, assessmentID, groupByName.Replace("     ", ""), dataItem["GroupByIDList"].Text);
        }
          
        /*
        //Modify this cell if this is being downloaded or printed
        if ((radGridOptions.IsGridDownloading) || (radGridOptions.IsGridPrinting))
        {
            dataItem["DesignTemplate"].Text = dataItem["DesignNA"] + "\t" + 
                                              dataItem["DesignFullCredit"] +
                                              dataItem["DesignPartialCredit"] +
                                              dataItem["DesignNoCredit"];
        }                
         */
    }        
}
Note that the commented out code does not work -- at least not as it is written.

And last but not least, I am attaching the data as it is exported into excel (gridexport.jpg)

   Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 16 Aug 2010, 05:43 PM
Hello Clint,

This RadGrid will be exported as expected if you replace the HyperLinks with Label or LiteralControls. Please refer to the attached demo for more information.

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Clint Leonard
Top achievements
Rank 1
answered on 16 Aug 2010, 06:21 PM
Thanks for the reply.  I will check this out and get back to you to mark as answered if/when it works.

thanks!
Tags
Grid
Asked by
Clint Leonard
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Clint Leonard
Top achievements
Rank 1
Share this question
or