Hi,
I am using 9.2.20092.2056.
I try to RIght align the text by:
<style type="text/css"> .RAlign { text-align:right; font-weight:bold;} </style>....
<ig:BoundDataField DataFieldName="FirstName" Header-Text="First Name" Key="FirstName" CssClass="RAlign" > <Header Text="First Name" /></ig:BoundDataField>
The font is bold which shows the CssClass is working.
But the text is not right align.
Did I miss anything?
Thanks!
David
Hello David,
The css class should have a selector like following:
<style type="text/css"> tbody > tr > td.RAlign { text-align:right; font-weight:bold;} </style>
Alex- can you demonstrate how to set a class like this in code-behind instead of in the designer? I've tried specifying it like this in the InitializeRow method:
e.Row.Items[i].Column.CssClass = "tbody>tr>td.RAlign";
...but it is not being recognized. Also, which file should contain the css tag? It's not at all clear which one is taking precedence.
Thanks-
Andy
Hello Andy,
It's not a good idea to use InitializeRow for assigning CssClass property off a column. Page_Load would be a better place to do so:
protected void Page_Load(object sender, EventArgs e)
{
wdg1.Columns[1].CssClass = "RAlign";
}
or if you have to do it from the InitializeRow event, check if it's the first row:
protected void wdg1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
if (e.Row.Index == 0)
e.Row.Items[1].Column.CssClass = "RAlign";
The css class can be defined in the <head> of aspx, or in an external css file, which is linked from inside of the <head> and it will take priority over the grid's styling:
<head runat="server">
<title></title>
<style type="text/css">
tbody > tr > td.RAlign
text-align:right;
font-weight:bold;
</style>
</head>
rockcityghost said: Problem is, if you add the class in the initialize row when filtering is enabled, it applies the RAlign to the Filter <TR>.
Problem is, if you add the class in the initialize row when filtering is enabled, it applies the RAlign to the Filter <TR>.
As an update, this code does nothing if filtering is off... I went to look through the samples, and guess what... They are so lame, no headers are centered or right aligned... Good job. Normal, dates and currencies should be right aligned, thus the reason we would want to right align the headers to match.
Here is the VB source code screen shot.
Then, if you try to use e.Row.Items[1].Column.Header.CssClass... Wait for it... Wait for it... IT DOES NOTHING.
Why do these controls have to be so hard to use...
IT'S SIMPLE, Make a friggin property. Grid.Column.Header.TextAlign and then, make it WORK.
Thanks Alex- this technique worked; however, it was necessary in this case to move the code inside the InitializeRow event, since the grid was bound to an untyped dataset and each cell is styled independently based on an external property. Meaning, the alignment to use is not known until run-time.
Also- I did not check for e.Row.Index == 0 as you suggested; it worked fine without that check...
- Thanks for your help -