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

[Solved] Grid sortable header text underline

3 Answers 286 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jeevitha
Top achievements
Rank 1
jeevitha asked on 29 Dec 2009, 10:13 AM

Hi..

I have a requirement in radgrid. Where ever we have Grid with sortable columns, the column header must be underlined. I tried the following code. it works well in FF but not in IE (previously i have customised the header text appearence by overwriting the css) 

<telerik:GridTemplateColumn HeaderStyle-Font-Underline="true"     HeaderText="Category Name" HeaderStyle-HorizontalAlign="Center"
                            SortExpression="Name"     HeaderStyle-Width="170px" ItemStyle-HorizontalAlign="Left"
                            ItemStyle-VerticalAlign="Middle">
                            <ItemTemplate>
                                <asp:LinkButton ID="lblShortCode" OnClick="EditeRecord" CommandArgument='<%# Eval("RecordID") + "~" +Eval("ProgramCatId") %>'
                                    runat="server" Text='<%# Eval("Name") %>'></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Middle" BorderColor="#8AB3C9" BorderWidth="1px"></ItemStyle>
                        </telerik:GridTemplateColumn>

Thanks.

Jeeivtha

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Dec 2009, 10:42 AM
Hello Jeevitha,

HeaderStyle-Font-Underline will not work, because hyperlinks do not inherit text-decoration CSS styles from parent elements. Please use the following CSS rule:


div.RadGrid_SkinName  .rgHeader  a ,   /* Q1 2009 + */
div.RadGrid_SkinName  .GridHeader_SkinName  a   /* Q3 2008 - */
{
       text-decoration: underline ;
}

The first selector is for new RadGrid versions, the second one is for older versions. You can use only one of them, according to your version.


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2009, 11:20 AM
Hello Jeevitha,

I tried the same setting with the latest version of RadGrid and found it to be working. I suppose you have set header css styles which overrides the inline setting. When sorting is enabled, the header text renders as a linkbutton. Thus, you can try accessing the linkbutton and set styles for it dynamically as shown below:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            ((LinkButton)header["TemplateColumnUniqueName"].Controls[0]).Font.Underline = true
        } 
    } 

Check if this helps..
Princy.
0
jeevitha
Top achievements
Rank 1
answered on 29 Dec 2009, 11:23 AM
Hi.. thanks Princy and Dimo.. both are  working... thanks for yr support

by
Jeevitha
Tags
Grid
Asked by
jeevitha
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Princy
Top achievements
Rank 2
jeevitha
Top achievements
Rank 1
Share this question
or