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

Apply Header CSS to First Cell in Each Row

3 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 19 Apr 2014, 08:29 PM
I want the first column in the grid (first cell of each row) to have the same style as the column headers. Since I allow the user to change themes/skins I don't want a hard-coded/static style... I want to reference the current skins CSS and apply the Header style to the first cell in each row. Is this possible? (makes the grid look like it has row headers but not really) Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Apr 2014, 05:12 AM
Hi Mike,

I guess you want to set style for the first column of the Grid. You can set the CSS using the ItemStyle property of that column in the PreRender event.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
 RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").ItemStyle.CssClass = "CSSClassName";
}

Thanks,
Princy
0
Mike
Top achievements
Rank 1
answered on 21 Apr 2014, 05:29 AM
Thank you... my problem is the "CSSClassName". I want to use the same class as the Grid Header for the given Skin. So, say I have the Forest skin... I assume the CSS I want is in this file (on my machine): C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q3 2013\Skins\Forest\Grid.Forest.css but I am just guessing. And I would assume the class to use would be... so, what do I use for the "CSSClassName"?:
.RadGrid_Forest .rgHeader, .RadGrid_Forest th.rgResizeCol, .RadGrid_Forest .rgHeaderWrapper {
  border: 0;
  border-bottom: 1px solid #3c6716;
  background: #4c7822 0 -2300px repeat-x url('Grid/sprite.gif'); }
0
Mike
Top achievements
Rank 1
answered on 21 Apr 2014, 05:36 AM
Nevermind... I got it. Thank You.
Private Sub RadGrid1_PreRender(sender As Object, e As System.EventArgs) Handles RadGrid1.PreRender
    RadGrid1.MasterTableView.GetColumn("row").ItemStyle.CssClass = "rgHeader"
End Sub




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