Close button not working after reopen window

6 posts, 0 answers
  1. Alex Dybenko
    Alex Dybenko avatar
    161 posts
    Member since:
    Jan 2005

    Posted 01 Jun 2020 Link to this post

    Hi,

    if I close RadWindow and then reopen it using .setVisible(true) on client side - close button in window title not working anymore. Is it possible to fix this?

    here a sample page, press open, close window, press reopen, try to close - nothing happens.

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
        <script type="text/javascript">
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
            function TestCloseDates() {
                var manager = GetRadWindowManager();
                var oWnd = manager.getWindowById('wndDates');
                oWnd.setVisible(true);
                //oWnd.restore();
                oWnd.setActive(true);
            }
        </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <input type="button" value="Open" onclick="window.radopen('', 'wndDates');"  />
            <input type="button" value="Reopen" onclick="TestCloseDates();"  />
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadWindowManager ID="wnd1" runat="server">
                <Windows>
                    <telerik:RadWindow Height="365px" Width="375px" ID="wndDates" runat="server" ReloadOnShow="True" >
                        <ContentTemplate>
                            Hi There!
                        </ContentTemplate>
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        </form>
    </body>
    </html>

    Thanks,

    Alex

     

  2. Vessy
    Admin
    Vessy avatar
    2369 posts

    Posted 04 Jun 2020 Link to this post

    Hi Alex,

    Calling the RadWindow's show() method instead of setVisible() will allow you not only to make the control's elements visible, but to be able to use its functionality (like buttons, etc):

            function TestCloseDates() {
                var manager = GetRadWindowManager();
                var oWnd = manager.getWindowById('wndDates');
                oWnd.show();
                oWnd.setActive(true); //you can skip this
            }

     

    Regards,
    Vessy
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Alex Dybenko
    Alex Dybenko avatar
    161 posts
    Member since:
    Jan 2005

    Posted 05 Jun 2020 in reply to Vessy Link to this post

    Hi Vessy,

    the problem with .show that window content get reloaded, but using .setVisible(true) - everything, what user selected/entered is kept.

    Is it possible to show window again, but keep it content plus close button working?

    Alex

  4. Vessy
    Admin
    Vessy avatar
    2369 posts

    Posted 10 Jun 2020 Link to this post

    Hi Alex,

    The content of RadWindow is not reloaded by default when the window is shown - https://www.screencast.com/t/x0W8xwRL

    Do you have any custom implementation forcing that?

    Below is the code I used for the recorded test. You can also try setting the ReloadOnShow="False" property of the window and see if this will bring the target result:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript">
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
            function TestCloseDates() {
                var manager = GetRadWindowManager();
                var oWnd = manager.getWindowById('wndDates');
                oWnd.show();
                oWnd.setActive(true); //you can skip this
            }
        </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <input type="button" value="Open" onclick="window.radopen('', 'wndDates');" />
            <input type="button" value="Open 2" onclick="window.radopen('', 'RadWindow1');" />
    
            <input type="button" value="Reopen" onclick="TestCloseDates();" />
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadWindowManager ID="wnd1" runat="server" ReloadOnShow="false">
                <Windows>
                    <telerik:RadWindow Height="365px" Width="375px" ID="wndDates" runat="server" ReloadOnShow="True">
                        <ContentTemplate>
                            Hi There!
                            <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox>
                        </ContentTemplate>
                    </telerik:RadWindow>
                    <telerik:RadWindow Height="365px" Width="375px" ID="RadWindow1" runat="server" ReloadOnShow="True">
                        <ContentTemplate>
                            Hi There!
                        </ContentTemplate>
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        </form>
    </body>
    </html>

    Regards,
    Vessy
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  5. Alex Dybenko
    Alex Dybenko avatar
    161 posts
    Member since:
    Jan 2005

    Posted 11 Jun 2020 in reply to Vessy Link to this post

    Hi Vessy,

    I need  ReloadOnShow, when user opens window, but also I need to give user option to show back closed window, which is actually hidden, with same content when it closed. Anyway, found this code, which solved my problem, can be useful for others, or myself after some time :)

    Alex

    Telerik.Web.UI.RadWindow.prototype.old_restore = Telerik.Web.UI.RadWindow.prototype.restore;
               Telerik.Web.UI.RadWindow.prototype.restore = function () {
                   this.old_restore();
                   if ($telerik.getVisible(this._popupElement))
                       this._popupVisible = true;
                   else
                       this._popupVisible = false;
               };
     
  6. Vessy
    Admin
    Vessy avatar
    2369 posts

    Posted 12 Jun 2020 Link to this post

    Hi,

    Thanks a lot for the clarification and the shared solution, Alex :) I am sure it will be very helpful to the other users facing the same issue.

    Kind regards,
    Vessy
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top