Column resizing starts behaving unexpectedly after hiding some columns using the header context menu and then re-ordering some columns.
I suspect it has something to do with the indexes getting confused with the javascript that does the resizing as only columns that are moved ahead of columns that were removed cause the resizing not to work correctly.
I have set up a test page that demonstrates this behaviour. Having EnableRealTimeResize set to True can really make things messy when this bug occurs.
ASPX
Code Behind:
To see the bug in action:
Open the header context menu and under columns uncheck "Loan Number", "Participants" and "Properties". After that re-order the columns so that they are ordered as follows:
| Policy Number | Order No | Policy Status | Order Status | Current Log point | Reference | Office | Created | Modified |
Now start resizing columns. The first 2 columns will resize just fine, but the "Policy Status" column will infact resize the "Current Log Point", "Reference", "Office", "Created" and "Modified" columns instead of its self.
I suspect it has something to do with the indexes getting confused with the javascript that does the resizing as only columns that are moved ahead of columns that were removed cause the resizing not to work correctly.
I have set up a test page that demonstrates this behaviour. Having EnableRealTimeResize set to True can really make things messy when this bug occurs.
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="FirstTitle.Web.TestPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
meta
http-equiv
=
"X-UA-Compatible"
content
=
"IE=8"
/>
<
title
>Grid Test</
title
>
<
style
media
=
"screen"
type
=
"text/css"
>
html, body
{
margin: 0;
padding: 0;
height: 100%;
}
#container
{
min-height: 100%;
position: relative;
_height:100%; /* Hack for IE 6 and below to fix up the crappy layout model */
}
#header
{
padding: 0px;
}
#content
{
padding-left: 25px;
padding-bottom: 1em; /* Height of the footer */
}
#footer
{
position: absolute;
bottom: 0;
width: 100%;
height: 1em; /* Height of the footer */
}
.contentDiv
{
overflow: auto;
position: relative;
*padding-bottom: 18px; /* Hack for IE 7 and below to fix up the crappy scrolling model */
*overflow-y: hidden; /* Hack for IE 7 and below to fix up the crappy scrolling model: * = IE7 and lower, _ = IE6 and lower */
}
.RadGrid
{
padding-right: 18px; /* Allows (to some degree) the right most column to be resized */
}
.paneIE
{
*position: relative;
}
</
style
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<%--Needed for JavaScript IntelliSense in VS2010--%>
<%--For VS2008 replace RadScriptManager with ScriptManager--%>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
Runat
=
"server"
Skin
=
"WebBlue"
/>
<
telerik:RadFormDecorator
ID
=
"RadFormDecorator1"
runat
=
"server"
DecoratedControls
=
"All"
/>
<
div
id
=
"container"
>
<
div
id
=
"header"
>
<
table
width
=
"100%"
border
=
"0"
cellpadding
=
"0"
cellspacing
=
"0"
>
<
tr
valign
=
"top"
>
<
td
colspan
=
"2"
valign
=
"top"
>
<
p
>Header</
p
>
</
td
>
</
tr
>
<
tr
>
<
td
valign
=
"top"
style
=
"padding-left: 25px; padding-bottom: 3px; padding-top: 3px;"
>
<
p
>Language Select</
p
>
</
td
>
<
td
align
=
"right"
valign
=
"top"
>
<
p
>|
Logout
|</
p
>
</
td
>
</
tr
>
</
table
>
</
div
>
<
div
id
=
"content"
>
<
div
class
=
"contentDiv"
>
<
telerik:RadGrid
ID
=
"rgPolicies"
runat
=
"server"
GroupingEnabled
=
"false"
GridLines
=
"None"
BorderStyle
=
"None"
AllowPaging
=
"True"
PageSize
=
"5"
AutoGenerateColumns
=
"False"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
OnPageIndexChanged
=
"rgPolicies_PageIndexChanged"
OnNeedDataSource
=
"rgPolicies_NeedDataSource"
>
<
ClientSettings
EnableAlternatingItems
=
"True"
EnableRowHoverStyle
=
"True"
AllowDragToGroup
=
"false"
AllowColumnHide
=
"true"
ColumnsReorderMethod
=
"Reorder"
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Resizing
AllowColumnResize
=
"True"
ResizeGridOnColumnResize
=
"True"
EnableRealTimeResize
=
"True"
/>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
ClientDataKeyNames
=
"OrderNo"
AllowMultiColumnSorting
=
"True"
AllowNaturalSort
=
"True"
EnableHeaderContextMenu
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OrderNo"
SortExpression
=
"OrderNo"
HeaderText
=
"Order No"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PolicyNumber"
SortExpression
=
"PolicyNumber"
HeaderText
=
"Policy Number"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OfficeName"
SortExpression
=
"OfficeName"
HeaderText
=
"Office"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CustomerReference"
SortExpression
=
"CustomerReference"
HeaderText
=
"Reference"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LoanNumber"
SortExpression
=
"LoanNumber"
HeaderText
=
"Loan Numbers"
AllowFiltering
=
"false"
AllowSorting
=
"false"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"BorrowerName"
SortExpression
=
"BorrowerName"
HeaderText
=
"Participants"
AllowFiltering
=
"false"
AllowSorting
=
"false"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SecurityAddress"
SortExpression
=
"SecurityAddress"
HeaderText
=
"Properties"
AllowFiltering
=
"false"
AllowSorting
=
"false"
>
<
HeaderStyle
Width
=
"125px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LogPointDescription"
SortExpression
=
"LogPointDescription"
HeaderText
=
"Current Log Point"
>
<
HeaderStyle
Width
=
"175px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderStatusTypeDescription"
SortExpression
=
"OrderStatusTypeDescription"
HeaderText
=
"Order Status"
>
<
HeaderStyle
Width
=
"175px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PolicyStatusDescription"
SortExpression
=
"PolicyStatusDescription"
HeaderText
=
"Policy Status"
>
<
HeaderStyle
Width
=
"175px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"CreatedDTime"
SortExpression
=
"CreatedDTime"
HeaderText
=
"Created"
FilterControlWidth
=
"100px"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"LastModDTime"
SortExpression
=
"LastModDTime"
HeaderText
=
"Modified"
FilterControlWidth
=
"100px"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"SalesOrderID"
HeaderText
=
"Sales Order ID"
Visible
=
"False"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
AlwaysVisible
=
"True"
></
PagerStyle
>
</
telerik:RadGrid
>
</
div
>
</
div
>
<
div
>
<
p
><
br
/>
M<
br
/>
o<
br
/>
r<
br
/>
e<
br
/>
<
br
/>
C<
br
/>
o<
br
/>
n<
br
/>
t<
br
/>
e<
br
/>
n<
br
/>
t<
br
/>
</
p
>
</
div
>
<
div
id
=
"footer"
>
<
p
>Footer</
p
>
</
div
>
</
div
>
</
form
>
</
body
>
</
html
>
Code Behind:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
Telerik.Web.UI;
namespace
FirstTitle.Web
{
public
partial
class
TestPage : System.Web.UI.Page
{
[Serializable]
public
struct
Policy
{
public
long
SalesOrderID {
get
;
set
; }
public
long
OrderNo {
get
;
set
; }
public
string
PolicyNumber {
get
;
set
; }
public
string
OfficeName {
get
;
set
; }
public
string
CustomerReference {
get
;
set
; }
public
string
LoanNumber {
get
;
set
; }
public
string
BorrowerName {
get
;
set
; }
public
string
SecurityAddress {
get
;
set
; }
public
string
LogPointDescription {
get
;
set
; }
public
string
OrderStatusTypeDescription {
get
;
set
; }
public
string
PolicyStatusDescription {
get
;
set
; }
public
DateTime CreatedDTime {
get
;
set
; }
public
DateTime LastModDTime {
get
;
set
; }
}
protected
void
rgPolicies_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
rgPolicies.DataSource = GetDataSource();
rgPolicies.CurrentPageIndex = (
int
)Session[
"CurrentPagingIndex"
];
}
protected
void
rgPolicies_PageIndexChanged(
object
source, GridPageChangedEventArgs e)
{
Session[
"CurrentPagingIndex"
] = e.NewPageIndex;
Policy[] ds = (Policy[])Session[
"SearchResultSet"
];
rgPolicies.CurrentPageIndex = e.NewPageIndex;
rgPolicies.DataSource = ds;
rgPolicies.DataBind();
}
private
Policy[] GetDataSource()
{
Policy[] ds;
if
(Session[
"SearchResultSet"
] ==
null
)
{
DoSearch();
}
ds = Session[
"SearchResultSet"
]
as
Policy[];
return
ds;
}
private
void
DoSearch()
{
Policy[] ds =
new
Policy[20];
for
(
long
i = 0; i < ds.Length; i++)
{
long
id = i + 1;
ds[i].SalesOrderID = id;
ds[i].OrderNo = id * 1000;
ds[i].PolicyNumber =
"POL"
+ (id * 10000).ToString();
ds[i].OfficeName =
"Office"
;
ds[i].CustomerReference =
"REF"
+ (id * 100).ToString();
ds[i].LoanNumber =
"LN"
+ id.ToString();
ds[i].BorrowerName =
"Borrower"
;
ds[i].SecurityAddress =
"Address"
;
ds[i].LogPointDescription =
"Log Point Name"
;
ds[i].OrderStatusTypeDescription =
"Order Status"
;
ds[i].PolicyStatusDescription =
"Policy Status"
;
ds[i].CreatedDTime = DateTime.Now.AddDays(id + 1 * -1);
ds[i].LastModDTime = DateTime.Now.AddDays(id * -1);
}
Session[
"SearchResultSet"
] = ds;
Session[
"CurrentPagingIndex"
] = 0;
rgPolicies.MasterTableView.Rebind();
}
}
}
To see the bug in action:
Open the header context menu and under columns uncheck "Loan Number", "Participants" and "Properties". After that re-order the columns so that they are ordered as follows:
| Policy Number | Order No | Policy Status | Order Status | Current Log point | Reference | Office | Created | Modified |
Now start resizing columns. The first 2 columns will resize just fine, but the "Policy Status" column will infact resize the "Current Log Point", "Reference", "Office", "Created" and "Modified" columns instead of its self.