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

How to change the width of the grid on column hide/show

5 Answers 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
idwaikat
Top achievements
Rank 2
idwaikat asked on 07 May 2009, 08:36 AM
Hi all

I have a very wide grid, I am using Header Context Menu to Hide/Show the columns then I save the settings of the grid using GridSettingsPersister mentioned in the help.

My problem is that when I hide columns, save settings, and on the next time I load the settings and apply it on the grid, then I show some hidden columns(using header context menu, the grid does not resize, instead, with width of the other columns decreased. I used: TableLayout="Fixed", but It did not work. The width of the grid and master MasterTableView is calculated on GridSettingsPersister as follows:

            double totalWidth = 0; 
 
            foreach (GridColumn column in gridInstance.MasterTableView.Columns) 
            { 
                Triplet triplet = new Triplet(); 
                
                    triplet = dict[column.UniqueName]; 
                    Unit width = (Unit)triplet.Second; 
                    column.OrderIndex = (int)triplet.First; 
                    column.HeaderStyle.Width = width; 
                    column.Display = (bool)triplet.Third; 
 
                    if((bool)triplet.Third) 
                        totalWidth += width.Value;                    
                 
               
            } 
            gridInstance.Width = Unit.Percentage(totalWidth); 
            gridInstance.MasterTableView.Width = Unit.Percentage(totalWidth); 

Settings the width to 100% does not fix the issue, also leaving it empty.

5 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 11 May 2009, 02:50 PM
Hello idwaikat,

Does enabling the column resizing for the control and setting ResizeGridOnColumnResize = true produces the desired result? You can see the effect on the following online demo of the product:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/resizing/defaultcs.aspx

Additionally, I think that using TableLayout = Auto is more appropriate in this case (to make the grid auto-size based on the cell content width).

Best regards,
Sebastian
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
idwaikat
Top achievements
Rank 2
answered on 11 May 2009, 03:02 PM
Setting ResizeGridOnColumnResize = true  does not fix the issue, I used it before, also I tried TableLayout = Auto, it did not fix it too. Also I saw your example before, it shocked me, I made exactly the same settings, but your demo differs from my project, because my project contains HeaderContextMenu, which makes the problem more bigger... becuase hiding/showing columns devastate the grid width.. that's the major point (HeaderContextMenu).

Regards
0
idwaikat
Top achievements
Rank 2
answered on 21 May 2009, 08:26 AM
Any suggestions???
0
Sebastian
Telerik team
answered on 21 May 2009, 08:40 AM

Hello idwaikat,

To provide up-to-the-point answer for your case, consider either providing a live url where the discrepancy can be observed or a simple test project (attached to a formal support ticket) which exhibits the abnormality. Thus we will be able to research the matter further and will get around to you with more info on the subject.

Best regards,

Sebastian
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
Nilar
Top achievements
Rank 1
answered on 15 May 2012, 07:23 PM
I would like to see the answer of the above issue. I am experiencing the same issue.
Tags
Grid
Asked by
idwaikat
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
idwaikat
Top achievements
Rank 2
Nilar
Top achievements
Rank 1
Share this question
or