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

header of the grid to group the columns

4 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
needy
Top achievements
Rank 1
needy asked on 29 Dec 2010, 05:12 PM

Hi
I'm using the telerik RadGrid. What I want to do is to add a row in the header of the grid to group the columns which has checboxes in it.
Currently I have the columns as GridCheckbox column in the masterview table.
Example:

<MasterTableView >
<Columns>
        
<telerik:GridCheckBoxColumn DataField="1" HeaderText="1"  />
        
<telerik:GridCheckBoxColumn DataField="2"  HeaderText="2" />
        <telerik:GridCheckBoxColumn DataField="3" HeaderText="3" />

 

 

 

 

 

All I want to do is just add a customer header that show two or more column headers grouped togeather. I don't need to group any data.
like

header 1: group Header
header 2:      1 2 3
and then the values of the columns 1 2 and 3 in check boxes

How can i do this?
Does anyone have any idea?

4 Answers, 1 is accepted

Sort by
0
needy
Top achievements
Rank 1
answered on 03 Jan 2011, 11:19 AM
I got my answer from another thread in the form  from the guy called Jason and it worked from me. He says


protected void rg_PreRender(object sender, EventArgs e) 
    //get the current header 
    GridItem[] header = rg.MasterTableView.GetItems(GridItemType.Header); 
    //get the current THead element 
    GridTHead head = ((GridTHead)header[0].Parent.Controls[0].Parent); 
    //Get the GridHeaderItem from the THead 
    GridHeaderItem currentHeaderItem = (GridHeaderItem)head.Controls[0]; 
    //Clear all GridHeaderItems 
    head.Controls.Clear(); 
    //create a new GridHeaderItem which will be the new row 
    GridHeaderItem newHeaderItem = new GridHeaderItem(rg.MasterTableView, 0, 0); 
 
    /*  My specific implementation for adding new row
    
    newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = "&nbsp;" });
    newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = "&nbsp;" });
    newHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = "&nbsp;", Width = new Unit(230, UnitType.Pixel) });
    for (int i = 0; i < statuses.Count; i++)
    {
        Entities.AssessmentStatus status = statuses[i];
        GridTableHeaderCell cell = new GridTableHeaderCell()
                                       {
                                           Text = status.Name,
                                           ColumnSpan = 2,
                                           HorizontalAlign = HorizontalAlign.Center
                                       };
        if (i != statuses.Count - 1)
            cell.Width = new Unit(145, UnitType.Pixel);
        newHeaderItem.Cells.Add(cell);
    }
    */ 
    //Add back the GridHeaderItems in the order you want them to appear 
    head.Controls.Add(newHeaderItem); 
    head.Controls.Add(currentHeaderItem); 

0
Maria Ilieva
Telerik team
answered on 03 Jan 2011, 12:21 PM
Hello,

We are glad you have found the answer in another forum post.
Do not hesitate to contact Telerik Support if future issues arise.


Regards,
Maria Ilieva
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
GTL Dev
Top achievements
Rank 2
answered on 27 Jul 2011, 07:46 PM
It would be more helpful to provide a link to the thread that helped to solve your issue instead of just saying "another thread in the form  from the guy called Jason "

Doesn't help anyone else out that may need the same info.
0
Maria Ilieva
Telerik team
answered on 28 Jul 2011, 04:16 PM
Hello,

I suppose that the useful forum is the below one:
http://www.telerik.com/community/forums/aspnet-ajax/grid/adding-multiple-header-rows-at-runtime-in-radgrid.aspx

Greetings,
Maria Ilieva
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.

Tags
Grid
Asked by
needy
Top achievements
Rank 1
Answers by
needy
Top achievements
Rank 1
Maria Ilieva
Telerik team
GTL Dev
Top achievements
Rank 2
Share this question
or