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

Radwindow popup

2 Answers 135 Views
Window
This is a migrated thread and some comments may be shown as answers.
Gauri
Top achievements
Rank 1
Gauri asked on 28 Jun 2013, 07:38 PM
I have a radgrid. It has edit enabled only for first row.
When the edit is clicked it opens a new radwindow to collect additional information.
Also the radgrid allows row drag and drop.
On rowdrop it checks if the new position is going to be first row it opens the new window to collect similar data for the new first row.
Now when the row is edited and then if the row is dragged and droped two windows open.
If we drag one more time three windows open.
Tried a few things like 
_menuwindow.DestroyOnClose = true;
WinManager.Windows.Clear();
But doesn't help.

Please help. How can I avoid opening unneccessary windows?
If I debug the code it doesn't really go to server to open the serverside window again.
I identify the two windows by giving different names server side and client side.

Any help is appreciated.
Thanks in advance.

Here is the code :

 protected void UIProceduresGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        GridDataItem gdItem = e.Item as GridDataItem;

        if (gdItem != null)
        {
            if (e.CommandName == "PDFEdit")
            {
                WinManager.Windows.Clear();
                
                RadWindow _menuwindow = new RadWindow();
                _menuwindow.NavigateUrl = "ProcedureDependantFactors.aspx";
                _menuwindow.VisibleOnPageLoad = true;
                _menuwindow.ShowContentDuringLoad = true;
                _menuwindow.Style.Value = "z-index:7010;";
                _menuwindow.ID = "ProcedureDependantFactors";                
                _menuwindow.Modal = true;
                _menuwindow.Height = 400;
                _menuwindow.Width = 900;
                _menuwindow.Title = "Procedure Dependant Factors Serverside";
                _menuwindow.DestroyOnClose = true;
               // _menuwindow.OnClientClose = "RefreshParentPage();";
                WinManager.Windows.Add(_menuwindow);
            }
        }
    }

function OnProcRowDropping(src, args) {
    //alert("Dragged grid row index is: " + args._dragedItems[0]._itemIndexHierarchical + "   Dropped target element index is: " + args._targetItemIndexHierarchical + "   Position : " + args._dropPosition);
    if (args._targetItemIndexHierarchical == 0 && args._dropPosition == 'above') {
        if (!confirm('There is another record marked as primary that record will no longer be primary. And the dependant records will be deleted. Are you sure you want to proceed?')) {
            args.set_cancel(true);
        }
        else {
            ShowPDF();
        }
    }
}

function ShowPDF() {
    var oManager = window.radopen("ProcedureDependantFactors.aspx");
    oManager.DestroyOnClose = true;
    oManager.Title = "Procedure Dependant Factors Clientside";
    oManager.set_animation(Telerik.Web.UI.WindowAnimation.Fade);
    oManager.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
    oManager.set_visibleStatusbar(false);
    oManager.set_visibleTitlebar(true);
    oManager.set_modal(true);
    oManager.set_height("500px");
    oManager.set_width("900px");
    oManager.center();
    oManager.SetActive();
    oManager.show();
}
























































2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 02 Jul 2013, 10:51 AM
Hello Gauri,

On opening a RadWindow from the server I strongly advise that you use the approach from this sticky thread: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx and that the same RadWindow is used in both cases. When you create a new instance and add it to the Windows collection of the manager it is persisted accross postbacks and the VisibleOnPageLOad property makes it show up after each postback. Also, the client-side event handlers of our controls only need the name of the JS function, without the parentheses, as explained in this blog post.

The ShowPDF() function creates a new RadWindow instance and in order to set its destroyOnClose property to true you need the set_destroyOnClose(true) method from the control's client-side API. You can call the same function from the code-behind.

You can even add a check through the RadWindowManager API - designate a name for the popup (the second argument to open(), as explained here) and from the manager getWindowByName() and then its isVisible() property - if it is already visible simply abort the function, show it only otherwise. Note that if radopen() or wndManager.open() are used first the call to .show() is not needed, else the show() call must come before the rest of the API is used. If you take this approach you can declare the desired properties of the popup in the markup and avoid the DestroyOnClose property. This will also allow you to avoid duplicate popups and, if suitable for your case, even avoid the postback that otherwise opened the popup.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Gauri
Top achievements
Rank 1
answered on 03 Jul 2013, 06:48 PM
Thanks Marin. That solved my problem.
Tags
Window
Asked by
Gauri
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Gauri
Top achievements
Rank 1
Share this question
or