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

Grid with multiple headers

8 Answers 302 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TelDev
Top achievements
Rank 1
TelDev asked on 11 Jan 2011, 01:52 PM
Hi,

I have a radgrid with some columns, In the code-behind i want to add another header on top of the existing header with column spans.
Where should i add this functionality, in prerender or itemcreated?
How to add the desired header.

Thanks
Babu

8 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Jan 2011, 08:56 AM
Hello TelDev,

RadGrid does not support multiple header rows with spanning header cells. You can achieve a similar layout by using a single GridTemplateColumn that has a table in the HeaderTemplate. This table can have multiple rows with spanning cells:

<telerik:GridTemplateColumn>
    <HeaderTemplate>
        <table>
            <tr>
                <td colspan="2">
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
            </tr>
        </table>
    </HeaderTemplate>
    <ItemTemplate>
        <table>
            <tr>
                <td>
                </td>
                <td>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</telerik:GridTemplateColumn>


Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
TelDev
Top achievements
Rank 1
answered on 17 Jan 2011, 11:20 AM
Thanks Veli,

I want to generate the table dynamically, That is why in code-behind.
Is there any other way.

Teldev
0
Veli
Telerik team
answered on 18 Jan 2011, 08:26 AM
Yes, here is a help  topic on how to create GridTemplateColumns programmatically.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
TelDev
Top achievements
Rank 1
answered on 19 Jan 2011, 10:00 AM
Thanks again,

I am not creating the entire grid dynamically, I want to create a new header over the existing header with column spans.
The column spans are decided dynamically, so the new header need to be created in either prerender or rowcreated event of grid.

Teldev
0
Veli
Telerik team
answered on 19 Jan 2011, 11:51 AM
OK, then try the following approach:

1. Use RadGrid's or Page's PreRender event to dynamically add another header row
2. Create a new GridHeaderItem and add it to the current header item's Parent control (it is of type GridTHead)
3. Add 2 empty GridTableHeaderCells to the new header item. These will not be visible, but they are required, as the grid has 2 hidden columns initialized every time.
4. Add as many other GridTableHeaderCells as you need, adjusting their colspans accordingly.

I have attached a test page to demonstrate this approach.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
TelDev
Top achievements
Rank 1
answered on 19 Jan 2011, 12:37 PM
Hi Veli,

It worked, Thanks
I used the same approach before but missed adding 2 empty GridTableHeaderCells  to header.

Thanks
Teldev
0
TelDev
Top achievements
Rank 1
answered on 02 Mar 2012, 03:18 PM
Hi,

I am also using a telerik grid with multiple headers as explained by you by adding 2 extra columns and then headers with column spans.
The headers with column spans has their own css class. The problem i am facing is the backgroud color of the top header. The scrollbar starts vertically from header 2, but not from header 1.
I have attched a image.

Thanks
TelDev
0
Veli
Telerik team
answered on 05 Mar 2012, 02:16 PM
Hi babu,

Using scrolling with static headers is not supported in the scenario with multiple header rows.

Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
TelDev
Top achievements
Rank 1
Answers by
Veli
Telerik team
TelDev
Top achievements
Rank 1
Share this question
or