I have created a telerik RadGrid in asp .net. My requirement is to give my own color to Column header. How can we achieve this...? Below is the code structure I'm using.
<Telerik:RadGrid ID="RadGrid2" runat="server">
<MasterTableView Width="100%" DataKeyNames="CustomerID" AllowMultiColumnSorting="True">
<DetailTables>
<telerik:GridTableView DataKeyNames="OrderID" Name="Orders" Width="100%">
<DetailTables>
<telerik:GridTableView DataKeyNames="OrderID" Name="OrderDetails" Width="100%">
<Columns>
<telerik:GridBoundColumn SortExpression="UnitPrice" HeaderText="Unit Price" HeaderButtonType="TextButton" DataField="UnitPrice">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Quantity" HeaderText="Quantity" HeaderButtonType="TextButton" DataField="Quantity">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton" DataField="OrderID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton" DataField="OrderDate" UniqueName="OrderDate" DataFormatString="{0:D}">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton" DataField="CustomerID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton" DataField="ContactName">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
And it should looks like image below:
Telerik automatically uses a skin for its grid. If you have not specified a skin it will use the Grid.Default skin. You can modify this skin or any of the skins to your own custom style. Just follow these steps.
Grid.Default.css (line 59)
.RadGrid_Default .rgHeader,
.RadGrid_Default th.rgResizeCol
{
border:0;
border-bottom:1px solid #828282;
background-color: Red;
/* background:#eaeaea 0 -2300px repeat-x url('Grid/sprite.gif'); */
}
Add a link to the css file that you modified on the page where you have your grid (or in the master page). <link href="Grid.Default.css" rel="stylesheet" type="text/css" />
Add the property EnableEmbeddedSkins="false" to your RadGrid. <telerik:RadGrid ID="RadGrid1" EnableEmbeddedSkins="false" runat="server">
This will tell the page to use your modified css file instead of the embedded one.
Telerik's web site has a blog post called How To Override Styles in a RadControl for ASP.NET AJAX' Embedded Skin that explains in detail how to override an existing style.