Radwindow keeps reopening after close.

3 posts, 1 answers
  1. Paul Gothard
    Paul Gothard avatar
    3 posts
    Member since:
    Nov 2008

    Posted 15 Apr 2010 Link to this post

    Hi,

    We have an issue where after closing a rad window (that is opened from a button in a grid using the ItemCommand) the page will do a post back to reload the grid after which the rad window automatically reopens.

    This function used to work fine without the rad window reopening. If I remove the rebind command from the close function the rad window does not reopen, however if you then cause the grid to rebind the window will reopen afterwards.

    The only changes I know have been done before it was noticed that this page now had an error, were an upgrade to the latest Telerik controls and the addtion of a method to keep the grid selections. (note that this is an Hierarchy grid and the button is on the data table not the master table)

    the Item command is as follows:
           if (e.CommandName == "GenerateExhibit")
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    //Get the primary key value using the DataKeyValue.    
                    string url = "~/Modules/Dialog/GenerateNewExhibit.aspx";
                    string arguments = "?Location=Chemical Lab";
                    arguments += "&IncidentId=" + IncidentId.ToString();
                    arguments += "&ParentExhibitId=" + item["ExhibitId"].Text;
                    arguments += "&ExtraDetail=" + item["Treatment"].Text;
                    RadWindow window = new RadWindow();
                    window.Title = "Generate New Exhibit";
                    window.ID = "rwGenerateNewExhibitDialogWindow";
                    window.NavigateUrl = url + arguments;
                    window.OnClientClose = "OnClientCloseGenerateNewExhibit";         
                    window.Behaviors = WindowBehaviors.Close;
                    window.KeepInScreenBounds = true;
                    window.VisibleStatusbar = false;
                    window.Modal = true;
                    window.Width = 1000;
                    window.Height = 750;
                    window.VisibleOnPageLoad = true;
                    rwmGenerateNewExhibit.Windows.Add(window);
                }

    the client side close function is:
                function OnClientCloseGenerateNewExhibit(radWindow) {
                    grdRelatedExhibits = $find("<%= grdRelatedExhibits.ClientID %>");
                    grdRelatedExhibits.get_masterTableView().rebind();
                    //alert("Closing");
                }

    the methods to 'remeber selection and expantion'
    protected void grdRelatedExhibits_DataBound(object sender, EventArgs e)
            {
                //Expand all items using our custom storage
                string[] indexes = new string[this.ExpandedStates.Keys.Count];
                this.ExpandedStates.Keys.CopyTo(indexes, 0);

                ArrayList arr = new ArrayList(indexes);
                //Sort so we can guarantee that a parent item is expanded before any of
                //its children
                arr.Sort();

                foreach (string key in arr)
                {
                    bool value = (bool)this.ExpandedStates[key];
                    if (value)
                    {
                        try
                        {
                            grdRelatedExhibits.Items[key].Expanded = true;
                        }
                        catch
                        {
                        }
                    }
                }

                //Select all items using our custom storage
                indexes = new string[this.SelectedStates.Keys.Count];
                this.SelectedStates.Keys.CopyTo(indexes, 0);

                arr = new ArrayList(indexes);
                //Sort to ensure that a parent item is selected before any of its children
                arr.Sort();

                foreach (string key in arr)
                {
                    bool value = (bool)this.SelectedStates[key];
                    if (value)
                    {
                        try
                        {
                            grdRelatedExhibits.Items[key].Selected = true;
                        }
                        catch
                        {
                        }
                    }
                }
            }

    Item command for expand/contract/select/deselect
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
                {
                    //Is the item about to be expanded or collapsed
                    if (!e.Item.Expanded)
                    {
                        //Save its unique index among all the items in the hierarchy
                        this.ExpandedStates[e.Item.ItemIndexHierarchical] = true;
                    }
                    else //collapsed
                    {
                        this.ExpandedStates.Remove(e.Item.ItemIndexHierarchical);
                        this.ClearExpandedChildren(e.Item.ItemIndexHierarchical);
                    }
                }
                //Is the item about to be selected
                else if (e.CommandName == RadGrid.SelectCommandName)
                {
                    //Save its unique index among all the items in the hierarchy
                    this.SelectedStates[e.Item.ItemIndexHierarchical] = true;
                }
                //Is the item about to be deselected
                else if (e.CommandName == RadGrid.DeselectCommandName)
                {
                    this.SelectedStates.Remove(e.Item.ItemIndexHierarchical);
                }

    Thanks in advance
    Paul



  2. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 15 Apr 2010 Link to this post

    Hello Paul,

    Please set EnableViewState=false in the RadWindowManager that you are using and you should not experience this problem anymore. Since Q3 2009 when a RadWindow is declared in  RadWindowManager  it preserves its ViewState which was not so in previous versions.

    Greetings,
    Georgi Tunev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Paul Gothard
    Paul Gothard avatar
    3 posts
    Member since:
    Nov 2008

    Posted 15 Apr 2010 Link to this post

    Many thanks for your quick reply.
    Thats all it was. :)
Back to Top