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

[Solved] setting HeaderStyle of radgrid

2 Answers 543 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Suvarna
Top achievements
Rank 1
Suvarna asked on 29 Dec 2009, 11:19 AM
Hello,

I am quiet weak in stylesheet .My query is not exactly related to radcontrols but its related to setting stylesheet for header. when the text of my header is greater than the width of that column, column increases it width automatically, i dont want to increase my column width. It will be ok if the text of header will overlap with the header of next column, how to set stylesheet for this. Quick reply will be appreciated.

Thanks in advance

Suvarna

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Dec 2009, 12:17 PM
Hello Suvarna,

Table cells normally expand to enclose their content. Please set TableLayout="Fixed" to the MasterTableView to prevent this expansion.

After this, depending on the RadGrid version, the header content will either overflow over the next column (older RadGrid versions) or it will be clipped (newer RadGrid versions).

If you are using some of the latest versions and still want the content to overflow, then use the following CSS rule:

.rgHeader
{
          overflow : visible  !important ;
}

If you are using some of the older versions and want the content to be clipped, then use the following CSS rule:

.rgHeader
{
          overflow : hidden  !important ;
}


By the way, it will be better and more convenient if you post your forum threads in the correct forum sections. Thank you.


Regards,
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
Shinu
Top achievements
Rank 2
answered on 29 Dec 2009, 12:45 PM
Hello Suvarna,

You can also show the complete text as a tooltip for the header cell after clipping the extra characters in the header text.

aspx:
 
<MasterTableView AutoGenerateColumns="False" EditMode="InPlace" TableLayout="Fixed" 
    CommandItemDisplay="Top" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID">    
    <Columns> 
       . . . 
        <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerIDLongheaderText" UniqueName="CustomerID"
            <HeaderStyle Width="100px" /> 
        </telerik:GridBoundColumn> 

cs:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem headerItem = (GridHeaderItem)e.Item; 
            headerItem["CustomerID"].ToolTip = headerItem["CustomerID"].Text; 
        } 
    } 

-Shinu.
Tags
Ajax
Asked by
Suvarna
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or