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

Grid common header, footer and alternating rows

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hary
Top achievements
Rank 1
Hary asked on 09 Sep 2008, 12:06 AM
Hello,

I am having hard time doing the following

1. having a common header for all the grid columns (client side hard coded value)

2. having a common footer for all the grid columns. This value comes from the server. so has to be set on the server side.

3. all the rows in the grid should have 2 alternating colors.

Could you please help me out accomplishing this ?

Thanks in advance
hary

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 09 Sep 2008, 04:42 AM
Hello Hary,

1.You can replace your columns with a TemplateColumn and customize the column to set a common header.Refer the following link to get more information on how to go about this.
Customizing with GridTemplateColumn

2.Once you set the TemplateColumn, you can access the Footer and customize it as shown in the code below.
cs:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridFooterItem) 
        { 
            GridFooterItem footeritem = (GridFooterItem)e.Item; 
            { 
                footeritem["TemplateColumn"].Text = "Footer"
                footeritem["TemplateColumn"].HorizontalAlign = HorizontalAlign.Center; 
            } 
        } 
    } 

3.You can try the following code to set alternating colors for the Grid rows.
aspx:
<telerik:RadGrid   ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound"
    <AlternatingItemStyle BackColor="Blue" /> 
    <ItemStyle BackColor="Red" /> 
      .... 
</telerik:RadGrid> 

Princy.

0
Hary
Top achievements
Rank 1
answered on 10 Sep 2008, 02:26 AM
Hi Princy,

Thanks a lot for your reply.

For some reason I can't use GridHeaderTemplate.
So what I did is that one of the databoundcolumns will have headertext and i disable the gridlines so that it would look like one single header for the whole grid.
For footer I do the same but lines between different footer columns won't go. I am unable to disable the border lines for footer of gridbound columns.

Also, is there a way to merger all these footers for different gridboundcolumns as one single row without using gridtemplate ? If that is possible then my life would become very easy..

One more thing. I am using Office2007 skin for my grid. I need to change the default header color for the grid. I know there's a CSS file (Grid.Office2007.css) in my local telerik folder where it picks all these values from. Can you tell me exactly which value should i change to change the header background color for the header of a gridboundcolumn ?

Please let me know.
Thanks,

Tags
Grid
Asked by
Hary
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Hary
Top achievements
Rank 1
Share this question
or