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

Grid width stays 100%

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 11 Feb 2011, 02:50 AM
I'd like my grid to be as wide as the columns that it is displaying but no matter what I do it seems to always take up the entire width of the screen. 
I have not specified a grid width (so there is no "width = 100%" anywhere).
I have specified column widths in my <headerstyle width="40px"/> tags for all my columns.
The sum of the widths of the 6-8 columns I have is nowhere near as wide as the screen but every time I load the page, the grid expands to fill it.
I have tried changing the table layout to "fixed" with no change in this behavior.
The only other oddity that I have is that there are several extra columns that I have defined but are set to visible = false.
I don't want to set a hard pixel width for the grid if I don't have to; I would like it to simply be as wide as the sum of it's fixed column widths.
Any idea what I'm not seeing/doing here?

Mike

2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 11 Feb 2011, 05:18 PM
Hello Mike,

The HTML output of the RadGrid control is not a single <table>, but also includes some <div>s in which the <table>s reside. Generally, the width of child elements depend on the width of parent elements - your wish is exactly the opposite, which is not possible in this case. Please set the RadGrid width explicitly, based on the column widths.

All the best,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ed
Top achievements
Rank 1
answered on 25 Jan 2012, 04:01 PM
Hi there,

I have a case where I don't know the width of my grid in advance as the number of columns varies (and hence I cannot specify it in pixels).  However, the grid always expands to fill the space of its containing <div /> element, sometimes with ridiculous results (if there are only a few columns in the table).  It is the same issue as that addressed in this older thread.  I have implemented the CSS work-around there with moderate success but am hoping an easier (i.e., automatic) solution may be on the horizon!

Ed Graham




Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ed
Top achievements
Rank 1
Share this question
or