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

Templated Columns -- setting font style to match other columns

5 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 01 Oct 2008, 10:44 AM
I have a templated column that contains a Label control (for databinding purposes).  I can set the text of the label just fine but the font for this column does not match the standard databound columns of the grid.  How can I set these templated columns to have the same style as the databound column.

Thanks,

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Oct 2008, 11:16 AM
Hello Randy,

You can generally set the font styles for the GridDataItems as shown below which will have an effect on both BoundColumns as well as TemplateColumns.
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item =(GridDataItem)e.Item; 
            item.Style.Add("font", "13px,Times New Roman,italic");            
        } 
   } 

Thanks
Princy.
0
Randy
Top achievements
Rank 1
answered on 01 Oct 2008, 11:45 AM
Ok but that is not exactly what I am after.  We are picking up the font styles from the skin.  I just want my template columns to use the same font size and style as the other bound columns.  What I am noticing is that my Label text looks to be using a slightly larger font than the other bound columns. 

0
Randy
Top achievements
Rank 1
answered on 01 Oct 2008, 12:39 PM
Also, I tried this suggestion and my embedded label inside of my templated control did not seem to pick up this style. 
0
Dimo
Telerik team
answered on 01 Oct 2008, 12:49 PM
Hi Randy,

All RadGrid embedded skins define styles on a table row basis, so normally there is no reason why a specific column should look different.

In my opinion, there are some styles outside the RadGrid skin, which could influence the appearance of span elements. Please check.

Another thing that could be happening is that you are inserting a <table> inside the template column cells and the web page is in quirks mode (no DOCTYPE). In this case the font size in the nested table is larger, because tables do not inherit font styles in quirks mode.

If you don't see anything suspicious, please send us your RadGrid declaration and your web application global stylesheet. Thanks.


Sincerely yours,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Randy
Top achievements
Rank 1
answered on 01 Oct 2008, 01:51 PM
Thanks I figured this out.  It was my problem.  I had declared a skin for the Label control that was getting in the way.  When I removed the skin, it worked as you stated.

thanks.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Randy
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or