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

[Solved] How set the total width of the grid?

2 Answers 287 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raymond
Top achievements
Rank 1
Raymond asked on 03 Jun 2011, 08:13 PM
All the grids I see on the example span the entire width of the containing block.

Is there a way to make the grid only as large as the column width contents?
This is slightly related to questiosn involving setting column widths -- however, they do not seem to work if I do not set Scrollable. (i.e. I do NOT want scroll bars).

Thanks.

2 Answers, 1 is accepted

Sort by
0
Rene
Top achievements
Rank 1
answered on 10 Jun 2011, 12:05 AM
Have you tried wrapping your grid in a div - something like this:

<div style="width:300px;">

GRID HERE

</div>
0
Atanas Korchev
Telerik team
answered on 10 Jun 2011, 07:42 AM
Hello,

 The Telerik Grid is rendered as an HTML table element. The latter do not accept column widths unless in fixed layout mode. The grid automatically goes in that table-layout: fixed mode if it is made scrollable. This can be also made using CSS:

.t-grid table
{
   table-layout:fixed;
}

You can set the width of the grid using its HtmlAttributes:

<%= Html.Telerik().Grid().HtmlAttributes(new { style = "width: 500px" } ) %>

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Raymond
Top achievements
Rank 1
Answers by
Rene
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or