Grid UnGroup Crash with EnableViewState=false

2 posts, 0 answers
  1. loowool
    loowool avatar
    60 posts
    Member since:
    Sep 2006

    Posted 15 Jun 2009 Link to this post

    Dear Telerik,

    We have a grid created in code (Q1 2009). When a user drags a column to the group header, it works great. When the column is dragged away from the header it UnGroups correctly.

    Recently we started optimizing the application. One thing we did is to set the EnableViewState=false on the Page containing the grid to make the page lighter

    <%@Page UICulture="auto" Language="C#" AutoEventWireup="true" EnableViewState="false" CodeFile="T.aspx.cs" Inherits="_T" %> 

    Everything worked great until we discovered a crash when the column is dragged away from the header. It gives the following dump:

    Exception.Message
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Stack Trace
    System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
    Telerik.Web.UI.GridGroupByExpressionCollection.get_Item(Int32 index)
    Telerik.Web.UI.GridGroupPanel.Ungroup(String index)
    Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument)
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    After various attempts to solve the problem with no luck, we put back the EnableViewState=true on the Page containing the grid:
    <%@Page UICulture="auto" Language="C#" AutoEventWireup="true" EnableViewState="true" CodeFile="T.aspx.cs" Inherits="_T" %> 
     
    And the crash disappeared.

    Note some other grid setting:

            radGrid.GridLines = GridLines.None;  
     
            radGrid.EnableViewState =  
            radGrid.AllowMultiRowSelection =  
            radGrid.ClientSettings.Selecting.AllowRowSelect =  
            radGrid.ClientSettings.Selecting.EnableDragToSelectRows = true;  
     
            radGrid.AllowAutomaticDeletes =  
            radGrid.AllowAutomaticInserts =  
            radGrid.AllowAutomaticUpdates =  
            radGrid.FilterMenu.Visible =  
            radGrid.ClientSettings.AllowKeyboardNavigation =  
            radGrid.MasterTableView.EnableColumnsViewState =  
            radGrid.AutoGenerateColumns = false;  
     
            radGrid.ClientSettings.ClientEvents.OnGridCreated = "GridCreated";  
            radGrid.ClientSettings.ClientEvents.OnKeyPress = "GridKeyPressed";  
            radGrid.ClientSettings.ClientEvents.OnRowSelected = "GridRowSelected";  
            radGrid.ClientSettings.ClientEvents.OnActiveRowChanged = "GridRowChanged";  
     
            radGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;  
     
            radGrid.MasterTableView.ClientDataKeyNames = new string[] { "uid" };  
     
            radGrid.ClientSettings.AllowColumnsReorder =  
            radGrid.ClientSettings.Resizing.AllowColumnResize =  
            radGrid.ClientSettings.Resizing.EnableRealTimeResize =  
            radGrid.ClientSettings.Resizing.ClipCellContentOnResize = radGrid.Columns.Count > 2;  
     
            radGrid.ClientSettings.AllowKeyboardNavigation =  
            radGrid.ClientSettings.Resizing.ResizeGridOnColumnResize = true;  
              
            radGrid.ClientSettings.ClientEvents.OnRowDblClick = "GridRowDoubleClicked";  
            radGrid.MasterTableView.SortExpressions.AllowNaturalSort = false;  
     
            radGrid.ShowGroupPanel =  
            radGrid.ClientSettings.AllowDragToGroup =  
            radGrid.ClientSettings.Scrolling.AllowScroll =  
            radGrid.AllowFilteringByColumn =  
            radGrid.ClientSettings.AllowGroupExpandCollapse = true;  
              
            radGrid.GroupingSettings.CaseSensitive = false;  
     
            radGrid.AllowPaging = true;  
            radGrid.PagerStyle.Mode = GridPagerMode.Slider;  
            radGrid.ClientSettings.Scrolling.SaveScrollPosition =  
            radGrid.ClientSettings.Scrolling.UseStaticHeaders =  
            radGrid.ClientSettings.Scrolling.AllowScroll = true;  
            radGrid.PreRender += new EventHandler(GridPreRender);  
     

    Can you please help?

    Salah A. Malaeb
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 17 Jun 2009 Link to this post

    Hi loowool,

    RadGrid does not manage grouping states when its ViewState is disabled. Please refer to the following help article for more information:

    Optimizing ViewState usage

    If you need to use grouping in RadGrid, its ViewState should be enabled.

    All the best,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top