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();