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

[Solved] Fixed Column Width & No Wrapping

2 Answers 202 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 09 Jul 2009, 01:17 PM
I would like to have fixed column widths on a grid and not allow a row to wrap onto multiple lines.  The way I've achieved this is to:-

1. Set TableLayout="Fixed"

2. Set fixed sizes in the ColumnCreated event...

        If (TypeOf e.Column Is GridBoundColumn) Then
            CType(e.Column, GridBoundColumn).HeaderStyle.Width = 140
            CType(e.Column, GridBoundColumn).DataFormatString = "<nobr>{0}</nobr>"
        End If

3. Apply a CSS Class to ItemStyle and AlternatingItemStyle...

            <ItemStyle CssClass="grid-row" />
            <AlternatingItemStyle CssClass="grid-row" />

4. My CSS Class is defined as follows...

            .grid-row td {overflow:hidden;}


Is this the best way to achieve this or is there a built in way or preferred way?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 09 Jul 2009, 02:39 PM
Hello Chris,

If you are using RadControls Q2 2009, points 3 and 4 are not necessary, because the overflow:hidden style is applied automatically.

In addition, you don't have to define custom CSS classes for rows or cells, because this will increase the control's HTML output. It is better to use the RadGrid's native CSS classes or set one custom CSS class to the RadGrid control itself.

For example, here is how to use the RadGrid's native CSS classes:

.RadGrid  .rgRow  td ,
.RadGrid  .rgAltRow  td
{
       overflow: hidden;
}

Here is how to use a custom CSS class set to the RadGrid control itself:

.MyClass  .rgRow  td ,
.MyClass  .rgAltRow  td
{
       overflow: hidden;
}



All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chris
Top achievements
Rank 2
answered on 09 Jul 2009, 02:48 PM
Thanks Dimo - just downloading Q2 now so will strip out 3 & 4 once I've installed that.

Many thanks,
Chris
Tags
Grid
Asked by
Chris
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Chris
Top achievements
Rank 2
Share this question
or