Hide/Show Radwindow from external javascript file

6 posts, 0 answers
  1. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2012 Link to this post

    Hi,

    I want to hide Radwindow from external javascript file, I  tried  various ways  to hide  Radwindow(without Radwindowmanager) but could not hide it completely.   With  " $find(delWindow).hide();" I was able to hide Radwindow but it did not hide the  semitransparent overlay.
    How can I call close()/hide() method on a Radwindow from external file?


    $find(delWindow).hide();
    $telerik.$("[id$='NGDeleteWindow']").hide(); . 



      //Hide Delete Window
                        function NGCloseDeleteWindow() {
                            var id = $telerik.$("[id$='DeleteWindow']").attr("id");
                            var delWindow = $find(id);
                            $find(delWindow).hide();  //$telerik.$("[id$='NGDeleteWindow']").hide(); 

                                                                      
                            //ClearNGridReferenceVariables();
                                                    
                        }




    Thanks,
    Prava
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 02 Oct 2012 Link to this post

    Hi Prava,

    There is a difference between the hide() and close() method of the RadWindow. If your RadWIndow is modal then hide() will keep the modal background, while close() will remove it. Most likely you need the close() method. The main problem is getting the ClientID in the external JavaScript file.

    The easier approach is to use the RadWindowManager's client-side API - its getWindowByName() method only needs the server ID which you can know because you know which one you opened.

    In all cases you need the proper reference to the control instance and not a jQuery object. You can use jQuery to get its ClientID and pass it to $find().

    All this means that your function seems fine, just replacing hide() with close() should get the desired behavior.


    Kind regards,
    Marin Bratanov
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 02 Oct 2012 Link to this post

    Hi  Bartanov,
     Using "RadwindowManager1.close()"   solved my problem.

    Thank you very much for your prompt response,
    Prava
  5. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2012 Link to this post

    My Dear, in order to close Radwindow , you can use this in javascript.
    1. Close Radwindow on button
    2. Close Radwindow on LinkButton
    3. Close Radwindow on ImageButton

        <script language="javascript">
                 function GetRadWindow() {
                     var oWindow = null;
                     if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog  
                     else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)         
                     return oWindow;
                 }

                 function closeWindow() {
                     GetRadWindow().Close();
                     GetRadWindow().BrowserWindow.location = parent.location;
                 }
        </script>

    <asp:Button ID="btn" runat="server" OnClientClick="closeWindow();" Text="Close RadWindow on Button" />
    <asp:LinkButton ID="lnkButton" runat="server" OnClientClick="closeWindow();" Text="Close RadWindow on LinkButton"></asp:LinkButton>
    <asp:ImageButton ID="imgButton" runat="server" OnClientClick="closeWindow();" ImageUrl="~/Images/close.png" />

    Regards
    Muhammad Waseem
  6. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 22 Apr 2013 Link to this post

    Hi,

    If I hide/close radwindwinow using external javascript file, I cannot open it again. Radwindow  object is null. However, it works fine if javascript code is embedded in aspx page.

       function1(){
                            //Getting rad window manager and hide radwindow
                            var oManager = GetRadWindowManager();
                            //Get an existing window DialogWindow using getWindowByName
                            var oWnd = oManager.getWindowByName("NGAddTktNotesWindow");
                            oWnd.close();

                           }
                         
    function2(){
                           //Getting rad window manager and show it.
                            var oManager = GetRadWindowManager();
                            //Get an existing window DialogWindow using getWindowByName
                            var oWnd2 = oManager.getWindowByName("NGAddTktNotesWindow");
                            oWnd2.show();

    }


    If function2 is called immediatley after calling function1, oWnd2 is null in external javascript file.
    How can I close/hide/show radwindow from external javavscript file?

    Thanks,
    Prava


  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 24 Apr 2013 Link to this post

    Hi Prava,

    The most likely reason for this behavior is that you have the DestroyOnClose property of the RadWindowManager set to true. Because of that the RadWindow object is disposed when the popup is closed, so it should be expected that you cannot get a reference to it any more.

    There are two ways to avoid this
    - set DestroyOnClose=false if you do not use dynamic instances
    OR
    - directly use the open() method of the manager, the second parameter is the window name that you want opened:
    http://www.telerik.com/help/aspnet-ajax/window-programming-radwindowmanager-methods.html
    http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-common.html - on why it would not remember its settings even in this case - see the Once a RadWindow is closed, it “loses” all its settings (width, height, modality, etc.) section

    Kind regards,
    Marin Bratanov
    the Telerik team
    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 their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017