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

Extra space in auto-sized columns

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan Frumin
Top achievements
Rank 1
Dan Frumin asked on 07 Apr 2010, 07:16 PM
I have a grid with auto-layout set and most of the columns are sized correctly.  However, the first three get lots of extra space to the right.  I'm attaching an image and my grid definition...

Any ideas where that's coming from?

thanks!

                <telerik:RadGrid ID="RadGrid1" Width="100%" Height="450px" AllowPaging="True" PageSize="15"  
                    runat="server" AllowSorting="False" OnNeedDataSource="RadGrid1_NeedDataSource" 
                    GridLines="None" AllowFilteringByColumn="False" ShowGroupPanel="False" EnableHeaderContextMenu="False" 
                    OnColumnCreated="RadGrid1_ColumnCreated" OnColumnCreating="RadGrid1_ColumnCreating" 
                    OnDataBound="RadGrid1_DataBound" OnPreRender="RadGrid1_PreRender" EnableViewState="false" 
                    OnItemDataBound="RadGrid1_ItemDataBound"
                    <HeaderContextMenu EnableAutoScroll="True"
                    </HeaderContextMenu> 
                    <MasterTableView Width="100%" AutoGenerateColumns="true" EnableColumnsViewState="false" TableLayout="Auto" /> 
                    <PagerStyle Mode="NextPrevAndNumeric"  
                        FirstPageImageUrl="/images/pagingfirst.gif"  
                        LastPageImageUrl="/images/paginglast.gif"  
                        NextPageImageUrl="/images/pagingnext.gif"  
                        PrevPageImageUrl="/images/pagingprev.gif" /> 
                    <ClientSettings AllowColumnsReorder="False" AllowDragToGroup="False" ReorderColumnsOnClient="False" 
                        Resizing-AllowColumnResize="False" Resizing-AllowRowResize="False" Resizing-ClipCellContentOnResize="False" 
                        Resizing-EnableRealTimeResize="True" Resizing-ResizeGridOnColumnResize="True"
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
                    </ClientSettings> 
                    <FilterMenu EnableTheming="False"
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                    </FilterMenu> 
                </telerik:RadGrid> 

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 08 Apr 2010, 08:58 AM
Hi Dan,

When using automatic table layout, the column widths are determined by the browser. If the RadGrid control occupies a certain amount of horiztonal space, the columns will expand to fill it. So I don't see a problem here. What exactly seems to be incorrect?

Sincerely yours,
Dimo
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.
0
Dan Frumin
Top achievements
Rank 1
answered on 08 Apr 2010, 09:21 AM
Hi Dimo,

I only screen capped the first three columns which are assigned lots of extra space.  There are 10'ish other columns that are all sized correctly (to their contents).  It's hard to show a picture of the whole thing but:

* I give the grid 900px in the browser
* The grid has 15 columns (for arguments sake)
* I tell the grid to auto-layout

The resulting grid is obviously larger than 900px and has a horizontal scrollbar (this is good).  Columns 4-15 are sized correctly to the content.  Columns 1-3 are much bigger than their contents.

In fact, looking more closely it seems that my other columns are only sized correctly because their headers are larger than twice the width of the data they contain.  I'm attaching an image of the whole grid (scrollbar included).  What's interesting is that the space allocated does seem to be twice as is needed.  So when the header is more than twice the width it looks good.

I tried an experiment and shrunk some headers and it gets more interesting.  One column (Form Factor became FF) repeated the pattern above (width remained twice the size of the items) while the other (Spot Impressions became SI) appropriately shrunk!  You can see that in the 2nd image.

So I'm confused.  :(

How do I lose that extra space?
0
Dimo
Telerik team
answered on 08 Apr 2010, 09:59 AM
Hello Dan,

The RadGrid behavior is correct. When you use static headers, RadGrid uses two tables - one of the header area and one for the data area. With auto layout, both tables are rendered with unsyncronized column widhts and the column widths are determined by the browser. The RadGrid control adjusts the header widths and data column widths by measuring which of the header and data is wider (per column) and assigning the width to the other table. As a result, some columns may turn out to be wider than expected.

The only way to change the behavior in this case is to assign explicit column widths (you can assign also percentage widths).

Sincerely yours,
Dimo
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
Dan Frumin
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Dan Frumin
Top achievements
Rank 1
Share this question
or