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

Hide column using js causes columns to grow, no longer lining up with header

1 Answer 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 May 2012, 08:58 PM
I have a grid, it is set to TableLayout Fixed. I have an explicit HeaderStyle with a width in px set on every column. Some columns have a display=False, I don't want them showing up initially. All databinding is done via javascript. I also have the following client settings:
<ClientSettings AllowColumnHide="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true" >
			   <ClientEvents 
               OnCommand="ReportSystem.RadGrid1_Command" 
               OnRowDataBound="ReportSystem.RadGrid1_RowDataBound" 
               OnColumnSwapped="ReportSystem.RadGrid1_OnColumnSwapped" 
               OnDataBindingFailed="ReportSystem.OnDataBindingFailed" />
				<Scrolling 
                AllowScroll="True" 
                UseStaticHeaders="True" 
                SaveScrollPosition="True">
				</Scrolling>
			</ClientSettings>

In javascript I call "hideColumn" with the index of the column to hide on the masterTableView. The column does hide correctly (and shows back up when i call the show function) But after each column is hidden every remaining column grows by a small amount exactly the same. As each column is shown, all the column widths shrink by the same amount they originally grew by. If instead I unhide one or more of the default hidden columns the columns stay correct, if I then start hiding columns, the widths stay correct until I hit the original number of columns then after that the columns start growing by that fixed amount.
Another weird part, this only happens in Chrome and IE, it seems to work correctly in firefox.

What could be causing the columns to grow?

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 24 May 2012, 12:00 PM
Hi Chris,

Your observation is correct. The experienced behavior could be caused when you are hiding columns and the scroll bar is hidden which cause the columns to try to resize in order to fit in the grid dimensions. I have assembled a sample project where if you hide one of the columns there will be no resizing of the other columns. This happens because the scroll bar remains visible and there is no need for additional corrections.

Additionally, if you set the grid width to 600 pixels and hide one of the columns you will observe the behavior described in your post.

Regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or