(in the screenshot I tried re-sizing "Total Acres" and instead it re-sized "Non Federal Acres" 2 columns over)
troubleshooting: I tried removing the hidden column and it did not affect the issue
current grid settings:
AutoGenerateColumns="true"
<GroupingSettings ShowUnGroupButton="true" CaseSensitive="false" />
<ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true">
<Selecting AllowRowSelect="true" />
<Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" />
<Scrolling SaveScrollPosition="false" AllowScroll="false" />
<ClientEvents OnPopUpShowing="PopUpShowing" />
</ClientSettings>3 Answers, 1 is accepted
Can you please elaborate a little bit more on the actual markup of the grid and how you populate the control with data as well as any other specific logic in code behind (how you bind it, whether you add remove columns dynamically, etc). Normally the control should not experience such issues unless there is some other custom code that interferes with the indexes of the columns. Providing the full markup and code behind for the grid can help us to replicate the issue and let you know how it can be resolved.
Greetings,Marin
the Telerik team
(note: for "EditFormSettings-UserControlName" we assign a default usercontrol but I have removed it here as the path has some sensitive information)
Markup for Grid:
<telerik:RadGrid ID="rgDynamic" runat="server" OnNeedDataSource="rgDynamic_OnNeedDataSource" OnItemDataBound="rgDynamic_ItemDataBound" OnItemCommand="rgDynamic_ItemCommand" PageSize="10" AllowSorting="true" AllowPaging="true" EnableLinqExpressions="false" ShowGroupPanel="true" AllowMultiRowSelection="false" EnableHeaderContextMenu="true" AllowFilteringByColumn="true" AutoGenerateColumns="true" EnableHeaderContextFilterMenu="true" Visible="false" OnColumnCreated="rg_ColumnCreated" OnExcelExportCellFormatting="rg_ExcelExportCellFormatting" OnPreRender="rg_PreRender" OnItemCreated="rgDynamic_ItemCreated"> <MasterTableView EditMode="PopUp" AllowMultiColumnSorting="true" CommandItemDisplay="None" InsertItemPageIndexAction="ShowItemOnCurrentPage"> <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="Top" /> <CommandItemSettings ShowRefreshButton="false" ShowAddNewRecordButton="true" ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="false" ShowExportToWordButton="true" /> <EditFormSettings EditFormType="WebUserControl"> <PopUpSettings Modal="true" Width="950px" Height="450px" ScrollBars="Auto" ZIndex="5000" CloseButtonToolTip="Close form and cancel any changes" /> <EditColumn UniqueName="editCommandColumn" ButtonType="ImageButton"> </EditColumn> </EditFormSettings> <Columns> <telerik:GridEditCommandColumn HeaderText="Edit" ButtonType="ImageButton" UniqueName="EditForm"> <HeaderStyle Width="50px" HorizontalAlign="Center" /> <ItemStyle Width="50px" HorizontalAlign="Center" /> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn HeaderText="Remove" ButtonType="ImageButton" UniqueName="DeleteCol" Visible="false" CommandName="Delete" ConfirmText="Are you sure you want to remove this? This action cannot be undone."> <HeaderStyle Width="60px" HorizontalAlign="Center" /> <ItemStyle Width="60px" HorizontalAlign="Center" /> </telerik:GridButtonColumn> <telerik:GridTemplateColumn HeaderText="Final Report" UniqueName="Finalreport" Visible="false"> <ItemTemplate>
<%--not functional, work in progress --%> Document Not Found </ItemTemplate> <HeaderStyle Width="120px"/> <ItemStyle Width="120px"/> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <GroupingSettings ShowUnGroupButton="true" CaseSensitive="false" /> <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true"> <Selecting AllowRowSelect="true" /> <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" /> <Scrolling SaveScrollPosition="false" AllowScroll="false" /> <ClientEvents OnPopUpShowing="PopUpShowing" /> </ClientSettings> <ExportSettings ExportOnlyData="true" IgnorePaging="true" HideStructureColumns="true" OpenInNewWindow="true"> </ExportSettings> </telerik:RadGrid>Code Behind Methods:
protected void rgDynamic_OnNeedDataSource(object o, GridNeedDataSourceEventArgs e) { if (!rgDynamic.Visible) return; Entities data = new Entities(); int key = getKey(); if (key > 0) { //note: this is an example of how we assign all our datasources for this grid string selectedMenu = getSelectedMenu(); //sets up up a delete column specific to the edit page try { GridColumn del = rgDynamic.Columns.FindByUniqueName("DeleteCol"); del.Visible = false; } catch { }//chooses datasource to assign based upon user's selections on an external menu switch (selectedMenu) { case "DataSource": var DataSource = (from p in data.Table where p.Key == key select new { BookID = p.BookID, Entry = p.Entry, Page = p.Page, Number = p.Number, Status = p.Status, Action = p.Action }); rgDynamic.DataSource = DataSource; rgDynamic.MasterTableView.EditFormSettings.UserControlName = "~/ControlTemplates/EditDataSource.ascx"; rgDynamic.MasterTableView.DataKeyNames = new string[1] { getDataKeyName() }; ShowAdminControls("Are you sure you want to delete this? This action cannot be undone.", true, false); break; //other similar case statements } rgDynamic.MasterTableView.CommandItemSettings.AddNewRecordText = "Create new " + selectedMenu; }}public void rg_PreRender(object o, EventArgs e) { RadGrid rg = (RadGrid)o; if (rg.Items.Count <= 0) { ////no data to display rg.MasterTableView.PagerStyle.AlwaysVisible = false; rg.MasterTableView.Width = Unit.Pixel(500); } else { rg.MasterTableView.PagerStyle.AlwaysVisible = true; rg.MasterTableView.Width = Unit.Percentage(100); }//other code that grabs and shows currently selected filters to user in a label}protected void rg_ColumnCreated(object sender, GridColumnCreatedEventArgs e) { //Default settings for all columns e.Column.FilterControlWidth = Unit.Percentage(50); e.Column.AutoPostBackOnFilter = true; e.Column.CurrentFilterFunction = GridKnownFunction.Contains; e.Column.ItemStyle.Width = Unit.Pixel(100); e.Column.HeaderStyle.Width = Unit.Pixel(100); string colName = e.Column.UniqueName.ToUpper(); if (colName == "BackgroundNumberData")//not the actual column names we're looking for
{ e.Column.Display = false; } else if (colName == "MoreDataSpecificColumnNames")//not the actual column names we're looking for
{ e.Column.Display = false; } else if (colName.EndsWith("ID")) { //hide all ID columns e.Column.Display = false; } if (colName.Contains("MEMO") || colName.Contains("DESCRIPTION") || colName.Contains("COMMENT")) { //make comment/memo/description fields wider e.Column.ItemStyle.Width = Unit.Pixel(250); e.Column.HeaderStyle.Width = Unit.Pixel(250); } else if (e.Column.DataType.ToString() == "System.DateTime") { //change format of date columns and change the default filter function e.Column.CurrentFilterFunction = GridKnownFunction.GreaterThanOrEqualTo; ((GridBoundColumn)e.Column).DataFormatString = "{0:MM/dd/yyyy}"; e.Column.FilterControlWidth = Unit.Percentage(55); e.Column.ItemStyle.Width = Unit.Pixel(125); e.Column.HeaderStyle.Width = Unit.Pixel(125); } else if (e.Column.DataType.ToString() == "System.Boolean") { //change width of checkbox columns and change the default filter function e.Column.CurrentFilterFunction = GridKnownFunction.EqualTo; e.Column.ItemStyle.Width = Unit.Pixel(80); e.Column.HeaderStyle.Width = Unit.Pixel(80); } }I excluded a few methods but none of the code inside those methods deal with columns or the radgrid.
Thank you for the provided sample code. I tested a page based on the same code (using version 2012.1.411) but could not replicate the described issue. You can find attached the sample page. Another thing that you can check is whether there is any additional code that shows or hides the columns of the grid which can cause issues with the resizing. And also if the problem appears when the grid has no hidden columns. Other than that I do not see any problems in the code that can lead to this behavior.
Kind regards,Marin
the Telerik team