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

GridTemplateColumn merged header w/Linkbutton export

2 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zach
Top achievements
Rank 1
Zach asked on 10 Nov 2009, 09:02 PM
I seem to be having an issue with the GridTemplateColumn.  In it, I have 2 headers and the top one spans over 3 columns.  On the bottom header, for each column I put in a linkbutton which allows the user to sort by that specific column.  Everything works fine and dandy except when I go to export the grid.  For some reason, it creates another row in excel below the bottom header, and merges the text of those linkbuttons into one cell on the new row.  If I changed those linkbuttons to just text, then it exports fine.

Here is the code for my grid:

<MasterTableView Width="947px" Name="gtvReport0"
    <Columns> 
        <t:GridTemplateColumn HeaderStyle-Width="300px" UniqueName="Payments" ShowSortIcon="false"
            <HeaderTemplate> 
                <table id="tablePmt1" style="width:100%;" class="myTable"
                    <tr> 
                        <td colspan="3" align="center">Payments</td> 
                    </tr> 
                    <tr> 
                        <td align="right"
                            <asp:LinkButton ID="lbSortByOneTimePmt" Text="One-Time" ToolTip="Click here to sort" CommandName='Sort' 
                                CommandArgument='Internet Payments' runat="server" Width="100%" /> 
                        </td> 
                        <td style="width:33%" align="right"
                            <asp:LinkButton ID="lbSortByRecurringPmt" Text="Recurring" ToolTip="Click here to sort" CommandName='Sort' 
                                CommandArgument='Recurring Payments' runat="server" Width="100%" /> 
                        </td> 
                        <td style="width:33%" align="right"
                            <asp:LinkButton ID="lbSortByTotalPmt" Text="Total" ToolTip="Click here to sort" CommandName='Sort' 
                                CommandArgument='Total Payments' runat="server" Width="100%" /> 
                        </td> 
                    </tr> 
                </table> 
            </HeaderTemplate> 
            <ItemTemplate> 
                <table id="tablePmt2" style="width:100%;" class="myTable"
                    <tr> 
                        <td align="right"><%#Eval("Internet Payments") %></td
                        <td style="width:33%;" align="right"><%#Eval("Recurring Payments")%></td
                        <td style="width:33%" align="right"><%#Eval("Total Payments")%></td
                    </tr> 
                </table> 
            </ItemTemplate> 
        </t:GridTemplateColumn> 
    </Columns> 
</MasterTableView>     

Any help would be appreciated.

Thanks in advance!
Zach

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 16 Nov 2009, 11:16 AM
Hello Zach,

The depicted behavior is probably caused by the fact that you set ExportOnlyData="true". As a result, RadGrid removes all controls (LinkButtons in this case) and the bottom header row appears empty. You can check this on your end if you set ExportOnlyData="false".

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Zach
Top achievements
Rank 1
answered on 16 Nov 2009, 02:34 PM
Daniel,

Thanks for the response, and yes your are correct.  I switched the ExportOnlyData to false and that made the link buttons appear in the correct columns in excel.

Since my users have a tendency to click on the link buttons in excel and call me up because it errors on them, I have to set ExportOnlyData to true.  To fix my issue, I basically placed labels along side the link buttons with the same text and made them hidden.  Then when I go to export the grid, I hide the link buttons and show the labels.  That makes the grid export correctly.

Thanks again!
Zach
Tags
Grid
Asked by
Zach
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Zach
Top achievements
Rank 1
Share this question
or