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

Column Resizing after Hiding and Re-Ordering columns not working properly

5 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 11 Nov 2010, 04:41 AM
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

 

 

 

<%@ 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">
  
    <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.

5 Answers, 1 is accepted

Sort by
0
Shane
Top achievements
Rank 1
answered on 12 Nov 2010, 01:24 AM
I have also just noticed that while reordering the columns if you look at the header context menu the columns that should be shown/hidden are also displayed wrong, it is unchecking columns that are still visible (see the attachment).
0
Shane
Top achievements
Rank 1
answered on 16 Nov 2010, 07:03 AM
After trying this in a few more browsers, it appears it only behaves this way in Internet Explorer 8. I could not reproduce the strange behaviour in any other browsers. However the header context menu column display ended up displaying wrong in every browser.
0
Pavlina
Telerik team
answered on 16 Nov 2010, 04:09 PM
Hi Shane,

The described behavior is an IE8 browser behavior and can be reproduced with an ordinary table as well.
To prevent it, you can either use scrolling with static headers, or emulate IE7 as it is explained in this article.
Also, I have notified our developers about this and they will be looking for a fix in the future versions of RadControls.

I hope this helps.

Sincerely yours,
Pavlina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Shane
Top achievements
Rank 1
answered on 18 Nov 2010, 01:03 AM
Using Scrolling with Static Headers does not fix anything, infact after you reposition the "Policy Status" column, all the columns after it collapse (see attachment) and the resizing bug still happens.

Emulating IE7 does fix this problem, but in a site designed to run in IE8 it causes display problems elsewhere on the page.

A fix would be great as for now we have to decide weather to accept the risk that our clients will be unhappy if during their customisation the grid resizing messes up if using IE8 or degrade the overall quality of the site in IE8 by using IE7 emulation so that the resizing will work right.

0
Pavlina
Telerik team
answered on 19 Nov 2010, 04:39 PM
Hi Shane,

Please excuse us for the inconvenience caused. If any other questions arise please do not hesitate to contact us again.

Sincerely yours,
Pavlina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Shane
Top achievements
Rank 1
Answers by
Shane
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or