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

Pivot Table with 1 header for multiple columns(grouped)

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sumith Jayasuriya
Top achievements
Rank 1
Sumith Jayasuriya asked on 12 Jun 2012, 05:58 PM
Hello Telerik Team,

Not sure if my title explains the situation properly, but here goes.  I'm basically making a grid email summary report using RadGrid. Basically my data comes back with columns such as: DateEnding, Area, Sent, Bounced, Clicks, etc, which I have successfully pivoted using the example provided.  My question is, is there a way to customize(or group maybe a better word) the headers of the columns.  I want the grid to display with DateEnding has the main header, and our 3 different area's under DateEnding as the subheaders.  The client wants to be able to easily compare mentioned metrics for a 4week period, across all areas.

Ideally the grid would look like : | 5/25/12 | 6/2/12 | 
|  North   |  South  |  West |  North   |  South  |  West | 

Please let me know if my explanation is not sufficient.  Maybe there is a better way to pull the data on my end to avoid this?  Any help is appreciated!

Thanks


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Jun 2012, 08:49 AM
Hi Sumith,

Please take a look into the following code snippet I tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" DataSourceID="SqlDataSource3" AutoGenerateColumns="false">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn HeaderText="OrderID" DataField="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                <HeaderTemplate>
                    <table id="Table1" cellspacing="1" cellpadding="1" width="300">
                        <tr>
                            <td colspan="3" align="center">
                                <b>OrderID</b>
                            </td>
                        </tr>
                        <tr>
                            <td width="50%">
                                <b>ShipName</b>
                            </td>
                            <td width="50%" >
                            <b>CustomerID</b>
                            </td>
                            <td width="50%">
                                <b>ShipCity</b>
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <table id="Table2" cellspacing="1" cellpadding="1" width="300">
                        <tr>
                            <td colspan="3" align="center">
                                <%# DataBinder.Eval(Container.DataItem,"OrderID") %>    
                            </td>
                        </tr>
                        <tr>
                            <td width="50%" >
                                <%# DataBinder.Eval(Container.DataItem,"ShipName") %>
                            </td>
                            <td width="50%">
                                <%# DataBinder.Eval(Container.DataItem,"CustomerID") %>
                            </td>
                            <td width="50%">
                                <%# DataBinder.Eval(Container.DataItem,"ShipCity") %>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Thanks,
Shinu.
Tags
Grid
Asked by
Sumith Jayasuriya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or