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

GridViewAutoSizeColumnsMode.Fill not working after columns grouping

1 Answer 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 03 Jul 2015, 06:23 PM

I have a grid view with several columns set where AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill.  I do have few columns with a fixed width (i.e. MinWidth = MaxWidth = Width).  This is working fine as you can see in picture Gridview1.  The gridview has the following properties:

this.RadGridViewTansBancaire.MasterTemplate.AllowAddNewRow = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowCellContextMenu = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowColumnChooser = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowColumnHeaderContextMenu = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowColumnReorder = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowDeleteRow = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowDragToGroup = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowEditRow = false;
this.RadGridViewTansBancaire.MasterTemplate.AllowRowResize = false;
this.RadGridViewTansBancaire.MasterTemplate.AutoExpandGroups = true;
this.RadGridViewTansBancaire.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;

 

Now, whenever I group these columns into 2 groups, the fill command is not working anymore as shown in picture Gridview2.

I tried several things, read the posts and the actual commands used are:

RadGridViewTansBancaire.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup(Offix.Culture.Traduire("BANQUE", "BANK")));
columnGroupsView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["BankDescription"]);
columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["BankReference"]);
columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["BankDate"]);
columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["BankMontant"]);

columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("OFFIX"));
columnGroupsView.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixJournal"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixNoJournal"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixDate"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixCode"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixNom"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixType"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixReference"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixNoDocument"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixDebit"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["OffixCredit"]);
columnGroupsView.ColumnGroups[1].Rows[0].Columns.Add(this.RadGridViewTansBancaire.Columns["Verifie"]);

RadGridViewTansBancaire.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
RadGridViewTansBancaire.BestFitColumns();

 

 

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Jul 2015, 11:34 AM
Hello Claude,

Thank you for contacting Telerik Support.

Your question has already been answered in the support thread you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it.

We have a known issue that the GridViewColumn.MinWidth is not respected when the AutoSizeColumnsMode property is set to Fill and ColumnGroupsViewDefinition is applied. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item. In the referred link there is suggested a sample approach for adjusting the columns width when resizing the grid considering the minimum width of the columns. Feel free to modify it on a way to achieve the required behavior.

I would like to note that when the AutoSizeColumnsMode property is set to Fill, â€‹columns automatically fill the entire width of the grid. However, calling the BestFitColumns() method distributes algorithm that attempts to fit in the header text and column data for all visible rows. The two approaches for adjusting columns width are different. Hence, it would be recommended either to best-fit the columns according to their content or to fill the columns according to the grid size.

I have tried to reproduce the broken fill columns functionality of RadGridView with the latest version but without any success. Could you please provide a full code snippet for the grid setup on your end in order to replicate the issue locally? Alternatively, you can provide a sample project demonstrating the undesired behavior in the support ticket. Thus, we would be able to investigate the precise case and assist you further. Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or