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

Override Header Cell Color

9 Answers 328 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 06 Dec 2011, 06:42 PM
I'm using a RadGrid with the theme Web20 and I'm having trouble changing the color for a specific cell in the RadGrid header. I noticed the header is using an image to create the gradient look, but I need to create the look of a spacer. I was able to accomplish this with the tree list, but I'm having issues doing this with the radgrid. See the pictures attached. 

I'm looking to do this in CSS on inline style or something that doesn't require a reference to System.Drawing in the VS project. Capture1.png below is the radgrid. Capture2.png is the treelist.

Thanks,

Derek

9 Answers, 1 is accepted

Sort by
0
Pablo
Top achievements
Rank 1
answered on 06 Dec 2011, 08:18 PM
Derek,

What you can do is the following is subscribe your grid to the itemcreate event and do the following:


protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{

            if(e.item.ItemType == GridItemType.Header

            {
                    //Change the background color of the header here
                    item.Style["background-color"] = "#b05a33";
                   
                    //Change the font if you would like
                  item.Style["color"] = "#FFFFFF";
                    item.Style["font-size"] = "9px";
             }            

 }

0
Shinu
Top achievements
Rank 2
answered on 07 Dec 2011, 06:24 AM
Hello Derek,

Try the following CSS.
CSS:
<style type="text/css">
 .RadGrid_Web20 th.rgHeader
 {
  color:Red;
 }
</style>

-Shinu.
0
Derek
Top achievements
Rank 1
answered on 07 Dec 2011, 04:00 PM
Thank you for your replies. I didn't have an issue changing the entire header, but I needed to do it for a specific column. I tried setting the HeaderStyle-CssClass, but the CSS change shows up behind the header theme. Any suggestions? I tried setting !important on the CSS and also tried setting z-index. Nothing helped.
0
Derek
Top achievements
Rank 1
answered on 11 Dec 2011, 11:36 PM
Any other ideas?
0
Accepted
Galin
Telerik team
answered on 12 Dec 2011, 02:24 PM
Hi Derek,

You should set the CssClass to the specific column, e.g.:
<telerik:RadGrid ID="RadGrid1" runat="server" ...>
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn UniqueName="Custom1" HeaderStyle-CssClass="specificHeader"></telerik:GridBoundColumn>
   ......
   ......
   ......
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

And use this CSS rule:
div.RadGrid .specificHeader
{
    background: #fff;
}

I hope it helps.

All the best,
Galin
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
0
Derek
Top achievements
Rank 1
answered on 12 Dec 2011, 04:08 PM
Thanks for your reply. That's the code that I have

aspx:
<telerik:GridTemplateColumn UniqueName="Spacer" HeaderStyle-Width="5px" 
	HeaderStyle-CssClass="RadGridSpacerCell" 
	ItemStyle-CssClass="RadGridSpacerCell" 
	HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" />

css:
div.RadGrid .RadGridSpacerCell
{
	background-color#FFFFFF;
}
If you look at the picture that I showed in the first post (capture 1 I believe) you can see the CSS is being picked up behind the image header, I just can't get it to pick up in front. If there is no easy way around this, then I don't want to do workaround for a styling issue.
0
Galin
Telerik team
answered on 12 Dec 2011, 04:35 PM
Hello Derek,

You should override the background-image too. Therefore, you should use background property instead of background-color:
background: #fff;

Best wishes,
Galin
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
0
Derek
Top achievements
Rank 1
answered on 12 Dec 2011, 04:55 PM
Something so minor! Thank you all very much!
0
Logan Marshall
Top achievements
Rank 2
Iron
answered on 24 May 2014, 01:56 AM
Yes! You've Saved that day!  I was just trying to override the "background-color" but the "background" css property needs changed too!  Genius.  I guess its a picture for the back ground for the source of rad grid/tree list column headers, for Web20 and Sunset for example?  Is that why you also need to change the background property?  Thanks Again!  Telerik You Rock!
Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Pablo
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Derek
Top achievements
Rank 1
Galin
Telerik team
Logan Marshall
Top achievements
Rank 2
Iron
Share this question
or